WCF web service error

WCF web service error

柠檬 发布于 2021-11-29 字数 1465 浏览 808 回复 2 原文

i give an error when connect my wcf service,

The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8)

My wcf service config file below this:

<?xml version="1.0"?>
<configuration>
    <customErrors mode="Off">
    </customErrors>
  <system.serviceModel>
    <services>
      <service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
        <!-- Service Endpoints -->
        <endpoint address="http://127.0.0.1/ChickenService/Service1.svc" binding="basicHttpBinding" contract="WcfService1.IService1">
          <identity>
            <dns value="127.0.0.1"/>
          </identity>
        </endpoint>
          <host>
          <baseAddresses>
            <add baseAddress="http://127.0.0.1/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfService1.Service1Behavior">
         <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

How can i solve this problem?

如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。

扫码加入群聊

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

没有心的人 2022-06-07 2 楼

It sounds like you are getting an ASP.NET Error Page (a.k.a "The Yellow Screen Of Death") when invoking your WCF service, which would explain why the response's MIME type is text/html.
Are you hosting your service in IIS?

After you have enabled exception details like Andrew suggested, you can copy the contents of the exception message you get back from the service, which will be a long HTML string, paste it in a new text file, save it as .HTML and open it in a web browser to look at the error details.

蓝眼睛不忧郁 2022-06-07 1 楼

Try changing this:

<serviceDebug includeExceptionDetailInFaults="false"/>

to this:

<serviceDebug includeExceptionDetailInFaults="true"/>

and see if the additional information in the error is helpful (also add that information to the post).