C# 如何在ASMXWeb服务(wsdl)中操作端口类型?

C# 如何在ASMXWeb服务(wsdl)中操作端口类型?,c#,web-services,binding,wsdl,C#,Web Services,Binding,Wsdl,我有一个ASMXWeb服务。在我的wsdl中,我猜测默认情况下生成的端口类型和绑定名称。我想要的是改变那些名字,我怎么做?它是否与配置文件相关,或者只有c#代码可以处理此问题。您建议使用如下wsdl的方式。 感谢您的回复 我的wsdl: <wsdl:message name="sendDocumentSoap12In"> <wsdl:part name="document" element="tns:documentRequest"/> </wsdl:message

我有一个ASMXWeb服务。在我的wsdl中,我猜测默认情况下生成的端口类型和绑定名称。我想要的是改变那些名字,我怎么做?它是否与配置文件相关,或者只有c#代码可以处理此问题。您建议使用如下wsdl的方式。 感谢您的回复

我的wsdl:

<wsdl:message name="sendDocumentSoap12In">
<wsdl:part name="document" element="tns:documentRequest"/>
</wsdl:message>
<wsdl:message name="sendDocumentSoap12Out">
<wsdl:part name="sendDocumentResult" element="tns:documentResponse"/>
</wsdl:message>

<wsdl:portType name="EFaturaSoap12">
<wsdl:operation name="sendDocument">
<wsdl:input message="tns:sendDocumentSoap12In"/>
<wsdl:output message="tns:sendDocumentSoap12Out"/>
</wsdl:operation>
</wsdl:portType>

<wsdl:binding name="EFaturaSoap12" type="tns:EFaturaSoap12">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sendDocument">
<soap12:operation soapAction="sendDocument" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>

我想要:

<wsdl:message name="sendDocument">
<wsdl:part element="tns:documentRequest" name="document"></wsdl:part>
</wsdl:message>
<wsdl:message name="sendDocumentResponse">
<wsdl:part element="tns:documentResponse" name="sendDocumentReturn"></wsdl:part>
</wsdl:message>

<wsdl:portType name="EFaturaPortType">
<wsdl:operation name="sendDocument">
<wsdl:input message="tns:sendDocument" name="sendDocument"></wsdl:input>
<wsdl:output message="tns:sendDocumentResponse" name="sendDocumentResponse"></wsdl:output>
<wsdl:fault message="tns:EFaturaFaultMessage" name="EFaturaFaultMessage"></wsdl:fault>
</wsdl:operation>
</wsdl:portType>

<wsdl:binding name="EFaturaSoapBinding" type="tns:EFaturaPortType">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sendDocument">
<soap12:operation soapAction="sendDocument" style="document"/>
<wsdl:input name="sendDocument">
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output name="sendDocumentResponse">
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="EFaturaFaultMessage">
<soap12:fault name="EFaturaFaultMessage" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>

您可以说,WSDL是您的配置文件。您可以手动但小心地更改它,就像上面所做的那样。您需要检查所有引用,以查看wsdl中值的变化。如上所述,您还需要使用新编辑的绑定名称编辑服务标记

任何语言的任何webservice实现都会对这些名称进行有限的控制。您可以在一定范围内控制这些名称

类似于jax-ws(用于XML-webservice的javaapi)。您可以根据方法或接口名称定义操作名称,端口类型取决于类名。通常在生成wsdl输入消息时:MethodNameRequest和输出消息:MethodNameResponse都会生成。我希望C#也会给出类似的实现

通常在wsdl中

•portType元素可以与传统编程语言中的函数库(或模块或类)进行比较

•操作元素可与传统编程语言中的方法进行比较

•消息元素定义操作或方法(输入/输出)的数据元素


如果您想经常使用wsdl进行这些更改,可以编写DOM解析器,根据您的需求生成带有更改的wsdl。

感谢@kingAm的回答,这对我很有帮助。