内容类型text / HTML; charset =响应消息的UTF-8与绑定的内容类型不匹配 [英] The content type text/HTML; charset=UTF-8 of the response message does not match the content type of the binding

查看:115
本文介绍了内容类型text / HTML; charset =响应消息的UTF-8与绑定的内容类型不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从调用我的WCF服务时收到以下错误



内容类型text / html; charset =响应消息的UTF-8与绑定的内容类型(application / soap + xml; charset = utf-8)不匹配。如果使用自定义编码器,请确保正确实现IsContentTypeSupported方法。响应的前1024个字节是:'#content {FONT-SIZE:0.7em; PADDING-BOTTOM:2em; MARGIN-LEFT:30px} BODY {MARGIN-TOP:0px; MARGIN-LEFT:0px;颜色:#000000; FONT-FAMILY:Verdana;背景颜色:白色} P {MARGIN-TOP:0px; MARGIN-BOTTOM:12px;颜色:#000000; FONT-FAMILY:Verdana} PRE {BORDER-RIGHT:#f0f0e0 1px solid; PADDING-RIGHT:5px; BORDER-TOP:#f0f0e0 1px solid; MARGIN-TOP:-5px; PADDING-LEFT:5px; FONT-SIZE:1.2em; PADDING-BOTTOM:5px; BORDER-LEFT:#f0f0e0 1px solid; PADDING-TOP:5px; BORDER-BOTTOM:#f0f0e0 1px solid; FONT-FAMILY:Courier New;背景颜色:#e5e5cc} .heading1 {MARGIN-TOP:0px; PADDING-LEFT:15px; FONT-WEIGHT:正常; FONT-SIZE:26px; MARGIN-BOTTOM:0px; PADDING-BOTTOM:3px; MARGIN-LEFT:-30px;宽度:100%;颜色:#ffffff; PADDING-TOP:10px; FONT-FAMILY:Tahoma; BACKGROUND-COLOR:#003366} .intro {MARGIN-LEFT:-15px}< title> MyService服务< DIV id =c'。



服务器堆栈跟踪:

在System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest请求,HttpWebResponse响应,HttpChannelFactory`1工厂,WebException responseException,ChannelBinding channelBinding)

在System.ServiceModel。 Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan超时)

在System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan超时)

在系统.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan超时)

在System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object [] ins,Object [ ]出,TimeSpan超时)

在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodC) System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)中的



用于托管WCF服务。



尝试在以下链接上提供的解决方案:



https:// forums。 asp.net/t/2021425.aspx?Content+type+text+xml+vs+application+soap+xml+issue



但我在下面找不到Windows Server 2003中的选项。



安装WCF非HTTP激活组件

1.单击开始按钮,然后单击控制。面板。

2.单击程序,然后单击程序和功能。

3.在任务菜单上,单击打开或关闭Windows功能。

4.找到.NET Framework 3.0节点,选择然后展开它。



任何帮助都会非常感激...



我的尝试:



内容类型(text / xml vs application / soap + xml)问题ASP.NET论坛 [ ^ ]



Jahith的技术分享:内容类型text / html;响应消息的charset = utf-8不匹配 [ ^ ]



我们还从生产服务器获取了相同的代码以及所有配置并将其部署在QA服务器(具有相同的操作系统配置),它正在工作。但它在生产服务器上不起作用。

I am getting below error while calling my WCF service from

The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}<title>MyService Service<DIV id="c'.

Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

We are using Windows server 2003 for hosting WCF service.

Tried solution provided on below links:

https://forums.asp.net/t/2021425.aspx?Content+type+text+xml+vs+application+soap+xml+issue

But I couldn't find below options in windows server 2003.

To install the WCF non-HTTP activation components
1. Click the Start button, and then click Control Panel.
2. Click Programs, and then click Programs and Features.
3. On the Tasks menu, click Turn Windows features on or off.
4. Find the .NET Framework 3.0 node, select and then expand it.

any help would be really appreciated...

What I have tried:

Content type (text/xml vs application/soap+xml) issue | The ASP.NET Forums[^]

Jahith's Tech Sharing: The content type text/html; charset=utf-8 of the response message does not match[^]

We also took same code from production server along with all configuration and deployed it on QA server (having same OS configuration) and it was working. But it doesn't work on production server.

推荐答案

Add the following code to the web.config server project

    <system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="basicHttpBinding_IService">
      <security mode="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service name="Service">
    <endpoint address="" name="BasicHttpBinding_IService"
              binding="basicHttpBinding"
              bindingConfiguration="basicHttpBinding_IService"
              contract="IService" />
  </service>
 </services>
</system.serviceModel>


then update client web service,After the update, the following changes are made web.config

    
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_IService">
      <security mode="Transport" />
    </binding>
  </basicHttpBinding>
</bindings>


  <endpoint address="https://www.mywebsite.com/Service.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
    contract="Service.IService" name="BasicHttpBinding_IService" />


I hope to be useful


这篇关于内容类型text / HTML; charset =响应消息的UTF-8与绑定的内容类型不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆