我在开发具有soap 1.2监听点的WCF服务。 该WCF服务使用以下自定义绑定:
<customBinding>
<binding name="httpsBinding" openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<transactionFlow />
<security authenticationMode="UserNameOverTransport" allowInsecureTransport="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" >
<secureConversationBootstrap allowInsecureTransport="true"></secureConversationBootstrap>
</security>
<textMessageEncoding messageVersion="Soap12">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<httpsTransport maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
使用以上配置程序,再通过fiddler调试,发送和接受的数据包的格式都正确 使用格式(soap 1.2)。数据包含如下特征:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header>...
WSDL上没有http://www.w3.org/2003/05/soap-envelope的引用。 尽管调用方法时它工作正常,但是这一直是个问题,因为WSDL没有正确描述服务。
解决以上问题只需要修改web.config 或者 app.config 文件,修改如下:
<Configuration>
<webServices>
<protocols>
<remove name="HttpSOAP"/>
<add name="HttpSOAP12" />
</protocols>
</webServices>
</configuration>
现在soap12的命名空间是需要声明: xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" ,经过修改发现以修改后有了soap1.2标识。