【发布时间】:2013-12-22 16:57:38
【问题描述】:
我在我的项目中创建了一个指向 Web 服务的链接(即添加服务引用 -> 高级 -> 添加 Web 服务引用)。
VS生成了一个代理类:System.Web.Services.Protocols.SoapHttpClientProtocol
WSDL 看起来像:
<definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
<types>
<xsd:schema ... >
<xsd:include schemaLocation="https://server.com/path/path/Serv?xsd=../path/path/path/name.xsd"/>
...
</xsd:schema>
</types>
<message name="Mes1_Message">
<part element="..." name="body"></part>
</message>
...
<message>...</message>
<portType name="name">
<operation name="Method1">
<input message="name" wsaw:Action="name"></input>
<output message="name" wsaw:Action="name"></output>
</operation>
...
</operation>
<binding name="name" type="type">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsaw:UsingAddressing xmlns:ns3="http://schemas.xmlsoap.org/wsdl/" required="true"/>
<wsaw:Anonymous>required</wsaw:Anonymous>
<operation name="Method1">...</operation>
<operation name="Method2">...</operation>
<service name="name">
<port binding="tns:name" name="name">
<soap12:address location="https://server.com/Serv"/>
</port>
</service>
</definitions>
如何向 SOAP 请求添加一些强制性数据?
<wsa:MessageID> ...</wsa:MessageID>
<wsa:ReplyTo> <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address></wsa:ReplyTo>
<wsa:Action>...</wsa:Action>
<wsa:To>...</wsa:To>
<wsa:RelatesTo></wsa:RelatesTo>
【问题讨论】:
-
欢迎来到 Stack Overflow! ASMX 是一项遗留技术,不应用于新开发。 WCF 或 ASP.NET Web API 应该用于 Web 服务客户端和服务器的所有新开发。一个提示:Microsoft 已停用 MSDN 上的 ASMX Forum。
-
您使用旧的“网络参考”有什么原因吗?他们不支持 WS-anything。
标签: c# visual-studio-2010 web-services soap asmx