简体   繁体   English

响应消息的内容类型 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

I know this question has been asked a few times before, but the solutions given either don't work for me or I'm too ignorant to fully understand how to implement the solution.我知道这个问题之前已经被问过几次,但是给出的解决方案要么对我不起作用,要么我太无知而无法完全理解如何实施该解决方案。

So, the website I am attempting to run runs off of a WCF client.因此,我尝试运行的网站运行在 WCF 客户端之外。 Whenever a WCF service tries to be called (ie, any database search or edit), it comes up with this error每当尝试调用 WCF 服务(即,任何数据库搜索或编辑)时,都会出现此错误

The content type text/html;内容类型 text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8).响应消息的 charset=utf-8 与绑定的内容类型(text/xml;charset=utf-8)不匹配。 If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly.如果使用自定义编码器,请确保正确实现 IsContentTypeSupported 方法。 The first 1024 bytes of the response were: '响应的前 1024 个字节是:'

When I make this error occur through an unhandled exception, this is what pops up当我通过未处理的异常发生此错误时,这就是弹出的内容

http://i.imgur.com/Vj7Baik.png http://i.imgur.com/Vj7Baik.png

(Note: the line that cuts off at the end reads) (注:最后截断的那一行是)

[ProtocolException: 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). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html>

Here is the web.config file used for the site (I'm not sure whether the problem is centered here, but I have a nagging suspicion it is)这是用于该站点的 web.config 文件(我不确定问题是否集中在这里,但我有一个唠叨的怀疑)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=localhost;Initial Catalog=DefaultConnection;Integrated Security=false;User ID=******;Password=******;"/>
    <add name="ITPDatabase" connectionString="Data Source=localhost;Initial Catalog=ITPDatabase;Integrated Security=false;User ID=******;Password=******;"/>
  </connectionStrings>
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Optimization" />
      </namespaces>
    <controls>
      <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
    </controls></pages>
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" defaultUrl="~/" timeout="2880" />
    </authentication>
    <profile defaultProvider="DefaultProfileProvider">
      <providers>
        <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
      </providers>
    </profile>
    <membership defaultProvider="DefaultMembershipProvider">
      <providers>
        <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
    </membership>
    <roleManager enabled="true" defaultProvider="DefaultRoleProvider">
      <providers>
        <add connectionStringName="DefaultConnection" applicationName="/"
          name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </providers>
    </roleManager>
    <sessionState mode="InProc" customProvider="DefaultSessionProvider">
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
      </providers>
    </sessionState>
  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService1" />
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="defaultServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    <endpointBehaviors>
      <behavior name="defaultEndpointBehaviour">
        <webHttp/>
      </behavior>
    </endpointBehaviors>
    </behaviors>
    <services>
    <service name="*****.Service1" behaviorConfiguration="defaultServiceBehaviour">
      <endpoint address="" binding="wsHttpBinding" contract="ServiceReference1.IService1"></endpoint>
    <endpoint address="http://<domainname>.com/Service1.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
        contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>

    </service>

    </services>

    <client>
    <endpoint address="http://<domainname>.com/Service1.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
        contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
    </client>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
        <handlers accessPolicy="Read, Execute, Script">
            <add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" resourceType="File" preCondition="integratedMode" />  </handlers>

    </system.webServer>


</configuration>

Now, from what I gathered of other questions, the gist of the error I'm receiving is instead of getting the xml response from the database, I'm getting a html page error.现在,从我收集的其他问题来看,我收到的错误的要点不是从数据库获取 xml 响应,而是收到 html 页面错误。

Before asking here I've been getting help from the web host's tech support, but at this point they're not sure what the problem is (or at least, the person who I was talking to was unsure) We used IIS to attempt to tinker with certain settings in the system (to no real change) so I can safely assume the site is hosting on IIS?在问这里之前,我一直在从网络主机的技术支持那里获得帮助,但此时他们不确定问题是什么(或者至少,我与之交谈的人不确定)我们使用 IIS 尝试修改系统中的某些设置(没有真正的改变),所以我可以安全地假设该站点托管在 IIS 上?

Any help on the matter is greatly appeciated.对此事的任何帮助都非常感谢。

You are getting a 500 error.您收到 500 错误。 This means the error is being thrown on the server hosting the service and not from the caller.这意味着错误是在托管服务的服务器上抛出的,而不是来自调用者。 My guess is bad data being sent to the service, like a null or string instead of int, or not sending all the required bits the service requires.我的猜测是向服务发送了错误数据,例如 null 或字符串而不是 int,或者未发送服务所需的所有必需位。

To get a more detailed error, you will either have to要获得更详细的错误,您要么必须

a) run the same request on the server hosting the service a) 在托管服务的服务器上运行相同的请求

eg - if your call to the service is http://www.domain.com/service.svc?id=1 , have them run the URL on the server where the service is hosted and send you the error.例如 - 如果您对服务的调用是http://www.domain.com/service.svc?id=1 ,请让他们在托管服务的服务器上运行 URL 并向您发送错误。

b) disable custom errors to get the actual error by modifying the web.config of the service b) 通过修改服务的 web.config 禁用自定义错误以获取实际错误

<configuration>
  <system.webServer>
    <httpErrors errorMode="Detailed" />
  </system.webServer>
  <system.web>
    <customErrors mode="Off" />
    <compilation debug="true" />
  </system.web>
</configuration>

暂无
暂无

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

相关问题 响应消息的内容类型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) 内容类型 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) 内容类型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) 响应消息的内容类型文本/纯文本与绑定的内容类型不匹配(文本/ 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 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) 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 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' 无法处理该消息,因为内容类型“ application / xml”不是预期的类型“ application / soap + xml”; 字符集= utf-8&#39; - Cannot process the message because the content type 'application / xml' was not the expected type 'application / soap + xml; charset = utf-8 '
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM