WCF 是否支持 SOAP 1.1 的 WS-Security?

发布于 2024-10-26 03:00:10 字数 1635 浏览 3 评论 0原文

我需要调用一些需要 WS-Security 的第三个 Web 服务。我使用以下配置创建了一个 WCF 端点:

<system.serviceModel>
  <bindings>
    <wsHttpBinding>
      <binding name="TestBinding">
        <security mode="TransportWithMessageCredential">
          <message clientCredentialType="Certificate" />
        </security>
      </binding>
    </wsHttpBinding>
  </bindings>
  <behaviors>
    <endpointBehaviors>
      <behavior name="TestBehavior">
        <callbackDebug includeExceptionDetailInFaults="true" />
        <clientCredentials>
          <clientCertificate findValue="Acme" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" />
          <serviceCertificate>
            <authentication certificateValidationMode="PeerOrChainTrust" />
          </serviceCertificate>
        </clientCredentials>
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <client>
    <endpoint address="https://acme.com/webservices" binding="wsHttpBinding" bindingConfiguration="TestBinding" behaviorConfiguration="TestBehavior" contract="AcmeContract" name="AcmeEndpoint"></endpoint>
  </client>
</system.serviceModel>

问题是第 3 方服务器抛出以下异常:

收到协议 '_http://schemas.xmlsoap.org/wsdl/soap12/', 所需协议 '_http://schemas.xmlsoap.org/wsdl/soap/'。

据我了解,使用 wsHttpBinding 将导致 WCF 发送 SOAP 1.2 请求,而使用 basicHttpBinding 将导致 SOAP 1.1 请求。据我了解,由于需要 WS-Security 部分,因此我必须使用 wsHttpBinding。我的问题是如何强制执行 SOAP 1.1 请求?我有什么选择?

I need to call some 3rd Web services that require WS-Security. I created a WCF endpoint with the following configuration:

<system.serviceModel>
  <bindings>
    <wsHttpBinding>
      <binding name="TestBinding">
        <security mode="TransportWithMessageCredential">
          <message clientCredentialType="Certificate" />
        </security>
      </binding>
    </wsHttpBinding>
  </bindings>
  <behaviors>
    <endpointBehaviors>
      <behavior name="TestBehavior">
        <callbackDebug includeExceptionDetailInFaults="true" />
        <clientCredentials>
          <clientCertificate findValue="Acme" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" />
          <serviceCertificate>
            <authentication certificateValidationMode="PeerOrChainTrust" />
          </serviceCertificate>
        </clientCredentials>
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <client>
    <endpoint address="https://acme.com/webservices" binding="wsHttpBinding" bindingConfiguration="TestBinding" behaviorConfiguration="TestBehavior" contract="AcmeContract" name="AcmeEndpoint"></endpoint>
  </client>
</system.serviceModel>

The problem is that the 3rd party servers a throwing the following exception:

Received protocol
'_http://schemas.xmlsoap.org/wsdl/soap12/',
required protocol
'_http://schemas.xmlsoap.org/wsdl/soap/'.

I understand that using the wsHttpBinding will cause WCF to send a SOAP 1.2 request while using the basicHttpBinding will result in a SOAP 1.1 request. Since the WS-Security parts are required, as I understand it, I have to use the wsHttpBinding. My question is how do I force a SOAP 1.1 request? What are my options?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情域 2024-11-02 03:00:10

为了使用 WS-Addressing (wsHttpBinding),但使用 SOAP 1.1(默认为 SOAP 1.2),您需要定义一个自定义 WCF 绑定(例如在配置中)并使用它

<bindings>
   <customBinding>
      <binding name="WsHttpSoap11" >
         <textMessageEncoding messageVersion="Soap11WSAddressing10" />
         <httpTransport/>
      </binding>
   </customBinding>
</bindings>

:您的端点定义,使用:

<endpoint name="WsSoap11"
    address="....."
    binding="customBinding"
    bindingConfiguration="wsHttpSoap11"
    contract="....." />

当然,您可以使用其他属性扩展上面定义的自定义绑定,例如 或其他属性。

有关 WCF 绑定以及如何在配置中“组合”您自己的自定义绑定的更详细、非常有用的信息,请阅读这篇优秀的 MSDN 文章 服务站:WCF 绑定深入,作者:Aaron Skonnard。

In order to use WS-Addressing (wsHttpBinding), but with SOAP 1.1 (SOAP 1.2 being the default), you need to define a custom WCF binding (e.g. in config) and use that:

<bindings>
   <customBinding>
      <binding name="WsHttpSoap11" >
         <textMessageEncoding messageVersion="Soap11WSAddressing10" />
         <httpTransport/>
      </binding>
   </customBinding>
</bindings>

and then in your endpoint definition, use:

<endpoint name="WsSoap11"
    address="....."
    binding="customBinding"
    bindingConfiguration="wsHttpSoap11"
    contract="....." />

Of course, you can extend the custom binding defined above with additional properties, e.g. <reliableMessaging> or others.

For more very detailed, very useful info on WCF bindings and how to "compose" your own custom bindings in config, read this excellent MSDN article Service Station: WCF Bindings In Depth by Aaron Skonnard.

沫离伤花 2024-11-02 03:00:10

您必须使用也支持 TransportWithMessageCredentials(SOAP 1.1 + HTTPS + WS-Security X.509 证书令牌配置文件)的 BasicHttpBinding,或者根据您的所有需求创建自定义绑定。

You must either use BasicHttpBinding which also supports TransportWithMessageCredentials (SOAP 1.1 + HTTPS + WS-Security X.509 Certificate Token profile) or create custom binding based on all your needs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文