我正在尝试将 WCF 客户端配置为能够使用返回以下响应消息的 Web 服务:
响应消息
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://myservice.wsdl">
<env:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" env:mustUnderstand="1" />
</env:Header>
<env:Body>
<ns0:StatusResponse>
<result>
...
</result>
</ns0:StatusResponse>
</env:Body>
</env:Envelope>
为此,我构建了一个自定义绑定(不起作用)。我不断收到“安全标头为空”消息。
我的绑定:
<customBinding>
<binding name="myCustomBindingForVestaServices">
<security authenticationMode="UserNameOverTransport"
messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11"
securityHeaderLayout="Strict"
includeTimestamp="false"
requireDerivedKeys="true">
</security>
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport authenticationScheme="Negotiate" requireClientCertificate ="false" realm =""/>
</binding>
</customBinding>
我的请求似乎使用与响应相同的 SOAP 和 WS 安全版本,但使用不同的命名空间前缀(“o”而不是“wsse”)。这可能是我不断收到“安全标头为空”消息的原因吗?
请求消息
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<o:UsernameToken u:Id="uuid-d3b70d1f-0ebb-4a79-85e6-34f0d6aa3d0f-1">
<o:Username>user</o:Username>
<o:Password>pass</o:Password>
</o:UsernameToken>
</o:Security>
</s:Header>
<s:Body>
<getPrdStatus xmlns="http://myservice.wsdl">
<request xmlns="" xmlns:a="http://myservice.wsdl" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
...
</request>
</getPrdStatus>
</s:Body>
</s:Envelope>
我需要如何配置我的 WCF 客户端绑定才能使用此 Web 服务?
非常感谢任何帮助!
桑德