簡體   English   中英

WCF http綁定錯誤:內容類型text / html與綁定的內容類型不匹配(text / xml; charset = utf-8)

[英]WCF http binding error: The content type text/html does not match the content type of the binding (text/xml; charset=utf-8)

我有一個WPF客戶端,它使用WCF服務,該服務是在Winforms應用程序中自托管的。 客戶端通過VPN連接訪問服務服務器。 首次初始化時,客戶端應用程序會從服務中捕獲異常:

There was a problem reaching the service. 
The content type of text/html of the response message does not match the content type of the binding (text/xml;charset=utf-8).
If using a custom encoder, be sure that the IsContentTypeSupported method is
implemented properly.

該服務正在運行而沒有問題,此問題僅在通過VPN連接時出現,而不是從與服務VM位於同一域的Visual Studio開發環境中出現:

在此輸入圖像描述

此異常僅在首次初始化時發生,當我再次運行客戶端應用程序時,問題已解決且所有內容都按預期運行。 這是我的服務應用程序配置:

  <services>
  <service name="IsesService.IsesService">                           
    <endpoint address="" binding="basicHttpBinding" contract="IsesService.IIsesService" bindingConfiguration="basicHttp">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>     
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://EMEA-DIIS01v:8082"/>
      </baseAddresses>
    </host>
  </service>
</services>

 <behavior>         
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
      <dataContractSerializer maxItemsInObjectGraph="2147483646" />          
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>

 <bindings>
  <basicHttpBinding>
    <binding name="basicHttp"
             useDefaultWebProxy="false"
             maxReceivedMessageSize="2147483647" 
             maxBufferSize="2147483647"
             maxBufferPoolSize="2147483647"
              >
      <readerQuotas maxArrayLength="2147483647"
                maxBytesPerRead="2147483647"
                maxDepth="2147483647"
                maxNameTableCharCount="2147483647"
                maxStringContentLength="2147483647"/>      
    </binding>
  </basicHttpBinding>
</bindings>

和客戶方:

  <system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IIsesService" useDefaultWebProxy="false"
             maxReceivedMessageSize="2147483647"
             maxBufferSize="2147483647"
             maxBufferPoolSize="2147483647">
              <readerQuotas maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxDepth="2147483647"
                        maxNameTableCharCount="2147483647"
                        maxStringContentLength="2147483647"/>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://emea-diis01v:8082/" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IIsesService" contract="ServiceReference.IIsesService"
            name="BasicHttpBinding_IIsesService" />
    </client>      
</system.serviceModel>

我錯過了一些簡單的東西嗎?

fiddler一起檢查第一個響應的內容是什么。 使用VPN時可能會有所不同。

暫無
暫無

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

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