简体   繁体   English

WCF 错误 A SOAP 1.2 消息在仅使用 wsHttpBinding 发送到 SOAP 1.1 时无效

[英]WCF Error A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only using wsHttpBinding

I am trying to consume a service which I have no control over and have been given just the WSDL to consume.我正在尝试使用我无法控制的服务,并且只获得了 WSDL 可以使用。 The service requires a certificate for authentication.该服务需要用于身份验证的证书。 My configuration for the certificate is fine and I get an error when I try and call the service as below:我的证书配置很好,当我尝试调用服务时出现错误,如下所示:

The content type text/xml;charset=UTF-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8).响应消息的内容类型 text/xml;charset=UTF-8 与绑定的内容类型不匹配(application/soap+xml; charset=utf-8)。 If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly.如果使用自定义编码器,请确保正确实现 IsContentTypeSupported 方法。 The first 274 bytes of the response were: 'soap:VersionMismatchA SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint.'.响应的前 274 个字节是:“soap:VersionMismatchA SOAP 1.2 消息在发送到 SOAP 1.1 only 端点时无效。”。

I have tried different this like using a customBinding but I landed up with a total new number of more errors and feel am not getting anyway.我已经尝试过不同的方法,比如使用 customBinding,但我遇到了更多新的错误,并且觉得无论如何都没有得到。 Can you please assist?你能帮忙吗?

Client Config:客户端配置:

<system.serviceModel>
    <client>
      <endpoint name="IDeliveryServiceImplPort" 
                address="WebServiceUrl" 
                binding="wsHttpBinding" 
                bindingConfiguration="wsHttpBinding"
                behaviorConfiguration="wsHttpCertificateBehavior"
                contract="IDeliveryService">
        <identity>
          <dns value="MyIdentity" />
        </identity>
      </endpoint>
    </client>

    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
                 receiveTimeout="00:10:00" sendTimeout="00:01:00"
                 bypassProxyOnLocal="false" transactionFlow="false"
                 hostNameComparisonMode="StrongWildcard"
                 maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                 messageEncoding="Text" textEncoding="utf-8"
                 useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas
            maxDepth="32" maxStringContentLength="8192"
            maxArrayLength="16384" maxBytesPerRead="4096"
            maxNameTableCharCount="16384" />
          <reliableSession enabled="false" ordered="true" inactivityTimeout="00:10:00" />
          <security mode="Transport">
            <message clientCredentialType="Certificate" />
          </security>
        </binding>
      </wsHttpBinding>
      <customBinding>
        <binding name="WsHttpSoap11"  closeTimeout="00:01:00" openTimeout="00:01:00"
                 receiveTimeout="00:10:00" sendTimeout="00:01:00">
          <textMessageEncoding messageVersion="Soap11WSAddressing10" />
          <security authenticationMode="MutualCertificate" />
          <httpsTransport requireClientCertificate="true" />
        </binding>
      </customBinding>
    </bindings>

    <behaviors>
      <endpointBehaviors>
        <behavior name="wsHttpCertificateBehavior">
          <clientCredentials>
            <clientCertificate x509FindType="FindBySubjectName" findValue="MyIdentity" storeLocation="LocalMachine" storeName="My" />
            <serviceCertificate>
              <defaultCertificate x509FindType="FindBySubjectName" findValue="MyIdentity" storeLocation="LocalMachine" storeName="My" />
              <authentication certificateValidationMode="PeerOrChainTrust" revocationMode="NoCheck" trustedStoreLocation="LocalMachine" />
            </serviceCertificate>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

I have managed to figure it out with tweaks and trials.我已经设法通过调整和试验来解决这个问题。 In order to solve is I change to basicHttpsBinding which took me another day or two to figure out the default transport clientCredentialType is None and you need to configure a custom binding as below.为了解决,我更改为 basicHttpsBinding 花了我一两天的时间来弄清楚默认传输 clientCredentialType 是 None 并且您需要配置一个自定义绑定,如下所示。 I wish WCF would tell you why or give a solution to error you get, because it was such a pain.我希望 WCF 能告诉你原因或解决你遇到的错误,因为这太痛苦了。 From one error description to the next nonstop.从一个错误描述到下一个不间断。

<bindings>
      <basicHttpsBinding>
        <binding name="SecureHubBinding">
          <security>
            <transport clientCredentialType="Certificate"  />
            <message clientCredentialType="Certificate" />
          </security>
        </binding>
      </basicHttpsBinding>
    </bindings>

Are these configurations automatically generated by adding service reference?这些配置是通过添加服务引用自动生成的吗? We can use the WSDL file of the service to generate the binding information used by the server-side and add the service reference to generate the client proxy class.我们可以使用服务的WSDL文件生成服务端使用的绑定信息,并添加服务引用生成客户端代理class。
In addition, if the service with transport security mode authenticates the client with a certificate, please guarantee that below requirements.另外,如果具有传输安全模式的服务使用证书对客户端进行身份验证,请保证满足以下要求。

  1. The trusted relationship between the client-side and the server-side should be established.应建立客户端和服务器端之间的信任关系。 Install mutual certificates in the Local CA.在本地 CA 中安装相互证书。
  2. These two certificates should be accessed by the WCF application.这两个证书应由 WCF 应用程序访问。 Please add the Everyone account (or the account running the WCF application) to the management group of the certificate private key.请将Everyone账户(或运行WCF应用程序的账户)添加到证书私钥的管理组。
  3. Both two certificates should have the client authentication intended purpose and the server authentication intended purpose.这两个证书都应具有客户端认证预期用途和服务器认证预期用途。

Feel free to let me know if there is anything I can help with.如果有什么我可以帮忙的,请随时告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM