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

我正在嘗試使用我無法控制的服務,並且只獲得了 WSDL 可以使用。 該服務需要用於身份驗證的證書。 我的證書配置很好,當我嘗試調用服務時出現錯誤,如下所示:

響應消息的內容類型 text/xml;charset=UTF-8 與綁定的內容類型不匹配(application/soap+xml; charset=utf-8)。 如果使用自定義編碼器,請確保正確實現 IsContentTypeSupported 方法。 響應的前 274 個字節是:“soap:VersionMismatchA SOAP 1.2 消息在發送到 SOAP 1.1 only 端點時無效。”。

我已經嘗試過不同的方法,比如使用 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>

我已經設法通過調整和試驗來解決這個問題。 為了解決,我更改為 basicHttpsBinding 花了我一兩天的時間來弄清楚默認傳輸 clientCredentialType 是 None 並且您需要配置一個自定義綁定,如下所示。 我希望 WCF 能告訴你原因或解決你遇到的錯誤,因為這太痛苦了。 從一個錯誤描述到下一個不間斷。

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

這些配置是通過添加服務引用自動生成的嗎? 我們可以使用服務的WSDL文件生成服務端使用的綁定信息,並添加服務引用生成客戶端代理class。
另外,如果具有傳輸安全模式的服務使用證書對客戶端進行身份驗證,請保證滿足以下要求。

  1. 應建立客戶端和服務器端之間的信任關系。 在本地 CA 中安裝相互證書。
  2. 這兩個證書應由 WCF 應用程序訪問。 請將Everyone賬戶(或運行WCF應用程序的賬戶)添加到證書私鑰的管理組。
  3. 這兩個證書都應具有客戶端認證預期用途和服務器認證預期用途。

如果有什么我可以幫忙的,請隨時告訴我。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM