WCF错误仅通过使用wsHttpBinding发送到SOAP 1.1时,SOAP 1.2消息无效

问题描述 投票:0回答:2

我正在尝试使用我无法控制的服务,而仅获得了要使用的WSDL。该服务需要用于认证的证书。我对证书的配置很好,尝试按如下所示调用服务时出现错误:

响应消息的内容类型text / xml; charset = UTF-8与绑定的内容类型不匹配(application / soap + xml;charset = utf-8)。如果使用自定义编码器,请确保IsContentTypeSupported方法已正确实现。第274章响应的字节为:'soap:VersionMismatch仅发送到SOAP 1.1时SOAP 1.2消息无效端点。”

我已经尝试过像使用customBinding这样的不同方法,但是我发现了更多新的错误,并且感觉仍然没有得到解决。您能帮忙吗?

客户端配置:

<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>
wcf soap x509certificate wcf-binding wcf-security
2个回答
0
投票

这些配置是否通过添加服务参考自动生成?我们可以使用服务的WSDL文件来生成服务器端使用的绑定信息,并添加服务引用以生成客户端代理类。此外,如果具有传输安全模式的服务通过证书对客户端进行身份验证,请确保满足以下要求。

  1. 客户端和服务器端之间的信任关系应该建立。在本地CA中安装相互证书。
  2. 这两个证书应由WCF应用程序访问。请添加所有人帐户(或运行WCF的帐户)应用程序)添加到证书私钥的管理组。
  3. 两个证书都应具有预期的客户端身份验证目的和服务器身份验证的目的。

随时告诉我是否有什么我可以帮助的。


0
投票

我设法通过调整和尝试解决了这个问题。为了解决这个问题,我更改为basicHttpsBinding,这又花了我一两天的时间来弄清默认的传输clientCredentialType为None,并且您需要按如下方式配置自定义绑定。我希望WCF会告诉您原因或为您遇到的错误提供解决方案,因为那是很痛苦的。从一个错误描述到下一个不间断。

<bindings>
      <basicHttpsBinding>
        <binding name="SecureHubBinding">
          <security>
            <transport clientCredentialType="Certificate"  />
            <message clientCredentialType="Certificate" />
          </security>
        </binding>
      </basicHttpsBinding>
    </bindings>
© www.soinside.com 2019 - 2024. All rights reserved.