【问题标题】:Trying to get WCF client to work with wss 1.0 username token security试图让 WCF 客户端使用 wss 1.0 用户名令牌安全性
【发布时间】:2010-04-30 21:00:08
【问题描述】:

我正在尝试使用 WCF 客户端调用第三方 Web 服务。 Web Service 使用用户名令牌认证 WSS-Security 1.0 Soap Message Security

这里是 web 服务期望的示例 soap 身份验证标头

<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>

但收到一个错误,指出标头中缺少 nonce 和 datecreated 属性。有谁知道如何配置 WCF 客户端以使用

WSS-Security 1.0 Soap Message Security 用户名令牌认证?

【问题讨论】:

    标签: wcf


    【解决方案1】:

    我遇到了同样的问题。我使用MessageInspectorBeforeSendRequest 方法中添加正确的UsernameToken,而不是自定义令牌序列化程序。然后我使用自定义行为来应用修复。

    整个过程记录在我的博文Supporting the WS-I Basic Profile Password Digest in a WCF client proxy 中(带有demo project)。或者,您可以阅读PDF

    如果您想了解我的解决方案进度,您可以在 StackOverflow 上找到标题为“Error in WCF client consuming Axis 2 web service with WS-Security UsernameToken PasswordDigest authentication scheme”的解决方案:

    【讨论】:

      【解决方案2】:

      一直在研究同样的问题,我的发现是不幸的是 WCF 不支持 Nonce 值。

      如果要发送用户名和密码(默认包含时间戳),请将配置更改为

           <basicHttpBinding>
              <binding name="BasicHTTP">
                <!-- UsernameToken over Transport Security -->
                <security mode="TransportWithMessageCredential">
                  <message clientCredentialType ="UserName" />
                </security>
              </binding>
            </basicHttpBinding>
      

      另请注意,在 WCF 和 WSS4J 之间交换时,关于 UserNameToken 似乎是一个缺陷(至少对标准的不同解释),请参阅http://social.msdn.microsoft.com/Forums/en/wcf/thread/6bc1b0e4-424b-4e2a-909c-815095be631f

      WSSConfig.getDefaultWSConfig().setAllowNamespaceQualifiedPasswordTypes(true);可能是 WSS4J 方面的一种解决方法。

      更新:在 WCF 方面,您可以通过实施 CustomCredential 和 CustomTokenSerializer 参考上一篇文章来解决这个问题 http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/4df3354f-0627-42d9-b5fb-6e880b60f8ee

      达芬奇

      【讨论】:

        猜你喜欢
        • 2020-12-20
        • 1970-01-01
        • 2014-04-24
        • 2011-04-25
        • 1970-01-01
        • 2017-01-30
        • 1970-01-01
        • 2014-09-23
        • 1970-01-01
        相关资源
        最近更新 更多