简体   繁体   English

内容类型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)

I created WCF service and testing WCF client using stand alone application. 我创建了WCF服务并使用独立应用程序测试WCF客户端。 I was able to view this service using Internet Explorer also able to view in Visual studio service references. 我能够使用Internet Explorer查看此服务,也可以在Visual Studio服务引用中查看。 Here is the error message. 这是错误消息。

"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)."

Could you please advice what could be wrong? 你能不能指出可能出错的地方?

Thank you. 谢谢。

Since the returned content type is text/html , I suspect your call result in a server-side error outside of WCF (you are receiving an HTML error page). 由于返回的内容类型是text/html ,我怀疑您的调用导致WCF之外的服务器端错误(您正在接收HTML错误页面)。

Try viewing the response with a web debugging proxy such as Fiddler . 尝试使用Fiddler等Web调试代理查看响应。


(Edit based on comments) : (根据评论编辑):

Based on your comments, I see that your WCF is hosted under Sharepoint 2010, in a form-authenticated site. 根据您的评论,我看到您的WCF在经过表单身份验证的站点中的Sharepoint 2010下托管。

The error you are receiving is due to the fact that your your WCF client is NOT authenticated with sharepoint -- it does not have a valid authentication cookie. 您收到的错误是由于您的WCF客户端未使用sharepoint进行身份验证 - 它没有有效的身份验证cookie。 Sharepoint then return an HTTP Redirect to an html page (the login.aspx page); 然后Sharepoint将HTTP重定向返回到html页面(login.aspx页面); which is not expected by your WCF client. 这是您的WCF客户端不期望的。

To go further you will have to obtain an authentication cookie from Sharepoint (see Authentication Web Service ) and pass it to your WCF client. 为了更进一步,您必须从Sharepoint获取身份验证cookie(请参阅身份验证Web服务 )并将其传递给您的WCF客户端。


(Updated edit) : (更新编辑):

Mistake: The site is using claim based authentication. 错误:该网站正在使用基于声明的身份验证。

Although this is not necessarily due to cookies or form authentication, the explaination of the provided error message remain the same. 虽然这不一定是由于cookie或表单身份验证,但提供的错误消息的解释保持不变。 An authentication problem cause a redirection to an HTML page, which is not handled by the WCF client. 身份验证问题导致重定向到HTML页面,而WCF客户端无法处理该页面。

这可能会有所帮助,请检查ISS 7中的URL重写规则。如果您没有正确配置规则,则会出现此问题。

text/html is SOAP 1.1 header and Content-Type: application/soap+xml is SOAP 1.2 Verify your bindings and return header. text / html是SOAP 1.1标头和Content-Type:application / soap + xml是SOAP 1.2验证绑定并返回标头。 It should be same either 1.1 or 1.2 应该是1.1或1.2相同

Add the following code to the web.config server project 将以下代码添加到web.config服务器项目中

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

then update client web service,After the update, the following changes are made web.config 然后更新客户端Web服务,更新后,进行以下更改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 我希望有用

It sounds like your application is expecting XML but is receiving plain text. 听起来您的应用程序期望XML但是接收纯文本。 What type of object are you passing in? 你传入的是什么类型的物体?

暂无
暂无

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

相关问题 内容类型 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) 响应消息的内容类型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) 响应消息的内容类型 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 响应消息的内容类型文本/纯文本与绑定的内容类型不匹配(文本/ 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) 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) 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 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) 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 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' 无法处理消息,因为内容类型为 &#39;application/json; charset=utf-8&#39; 不是预期的类型 &#39;text/xml; 字符集=utf-8&#39; - 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