我正在尝试使用 WCF 客户端调用第三方 Web 服务。 Web 服务使用用户名 token 身份验证 WSS-Security 1.0 Soap 消息安全
这是 Web 服务期望的示例 soap 身份验证 header
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<wsse:Security soap:mustUnderstand="1">
<wsse:UsernameToken namespaces>
<wsse:Username>username</wsse:Username>
<wsse:Password Type="type info">password</wsse:Password>
<wsse:Nonce>nonce</wsse:Nonce>
<wsu:Created>date created</wsu:Created>
</wsse:UsernameToken>
<wsse:Security>
</soap:Header>
<soap:Body>
<WebServiceMethodName xmlns="Web Service Namespace" />
我是这样配置客户端的
<basicHttpBinding>
<binding name="Binding1">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Basic"/>
</security>
</basicHttpBinding>
但收到一个错误,指出 header 中缺少 nonce 和 datecreated 属性。有谁知道如何配置 WCF 客户端以使用
WSS-Security 1.0 Soap 消息安全用户名 token 身份验证?
最佳答案
我遇到了同样的问题。我使用 MessageInspector
在 BeforeSendRequest
方法中添加正确的 UsernameToken
而不是自定义 token 序列化器。然后我使用自定义行为来应用修复。
我的博客文章 demo project 中记录了整个过程(带有 Supporting the WS-I Basic Profile Password Digest in a WCF client proxy) .或者,您可以只阅读 PDF .
如果您想了解我的解决方案,您会在 StackOverflow 上找到标题为“Error in WCF client consuming Axis 2 web service with WS-Security UsernameToken PasswordDigest authentication scheme”的解决方案:
关于wcf - 试图让 WCF 客户端使用 wss 1.0 用户名 token 安全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2747654/