简体   繁体   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)

I have a WPF client which consumes a WCF service which is self hosted in a Winforms app. 我有一个WPF客户端,它使用WCF服务,该服务是在Winforms应用程序中自托管的。 The client is accessing the service server via a VPN connection. 客户端通过VPN连接访问服务服务器。 At first initialisation, the client app catches an exception from the service: 首次初始化时,客户端应用程序会从服务中捕获异常:

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.

The service is running without issue and this issue only appears when connecting via VPN, not from my Visual Studio development environment which is on the same domain as the service VM: 该服务正在运行而没有问题,此问题仅在通过VPN连接时出现,而不是从与服务VM位于同一域的Visual Studio开发环境中出现:

在此输入图像描述

This exception only occurs on first initialisation, when I run the client app again, the issue is resolved & everything runs as expected. 此异常仅在首次初始化时发生,当我再次运行客户端应用程序时,问题已解决且所有内容都按预期运行。 Here is my service app config: 这是我的服务应用程序配置:

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

And client side: 和客户方:

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

Am I missing something simple here? 我错过了一些简单的东西吗?

Check with fiddler what is the content of the first response. fiddler一起检查第一个响应的内容是什么。 It is probably different when you use VPN. 使用VPN时可能会有所不同。

暂无
暂无

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

相关问题 响应消息的内容类型 application/xml;charset=utf-8 与绑定的内容类型(text/xml; charset=utf-8)不匹配,WCF - The content type application/xml;charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8), WCF 内容类型text / html; charset =响应消息的UTF-8与绑定的内容类型不匹配(text / xml; charset = utf-8) - The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8) wcf +响应消息的内容类型text / html与绑定的内容类型不匹配(application / soap + xml; charset = utf-8) - wcf + The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8) 内容类型 text/xml; 响应消息的 charset=&quot;utf-8&quot; 与绑定的内容类型不匹配 (text/xml; charset=utf-8) - The content type text/xml; charset=“utf-8” of the response message does not match the content type of the binding (text/xml; charset=utf-8) 响应消息的内容类型文本/纯文本与绑定的内容类型不匹配(文本/ xml; charset = utf-8) - The content type text/plain of the response message does not match the content type of the binding (text/xml; charset=utf-8) 响应消息的内容类型application / xml; charset = utf-8与绑定的内容类型不匹配(text / xml; charset = utf-8) - The content type application/xml;charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8) WCF 服务客户端:内容类型text/html; 响应消息的 charset=utf-8 与绑定的内容类型不匹配 - WCF Service Client: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding C#ASMX服务抛出内容类型text / html; charset =响应消息的UTF-8与内容类型错误不匹配 - C# ASMX Service throwing The content type text/html; charset=UTF-8 of the response message does not match the content type error Wcf 服务,我收到此错误:内容类型 text/html; 字符集=utf-8 - Wcf Service, I'm getting this error: The content type text/html; charset=utf-8 HTTP 415 无法处理消息,因为内容类型为“application/json; charset=utf-8&#39; 不是预期的类型 &#39;text/xml; 字符集=utf-8&#39; - HTTP 415 Cannot process the message because the content type 'application/json; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM