【发布时间】:2013-03-11 15:26:33
【问题描述】:
我在尝试将 WCF 服务添加到 WCFTestClient 时收到以下错误。我在网上浏览了许多解决方案,但我无法让它工作。
有人可以帮我解决这些问题吗? 我还提供了我的服务配置文件:
内容类型 application/soap+xml; charset=utf-8 不受支持 service 客户端和服务绑定可能不匹配。这 远程服务器返回错误:(415)无法处理消息 因为内容类型'application/soap+xml; charset=utf-8' 不是 预期类型'text/xml;字符集=utf-8
代码:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file
must be added to the host's app.config file. System.Configuration does not
support config files for libraries. -->
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttp" allowCookies="true"
maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="WCFTradeLibrary.TradeService">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="basicHttp"
contract="WCFTradeLibrary.ITradeService">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint
above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faul`enter code here`ts for
debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception info`enter code here`rmation -->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
【问题讨论】:
-
这是一个老问题,但它显示为谷歌的第一个答案。我只想指出错误消息可能具有误导性。潜在的错误可能完全不相关......这发生在我身上。
-
向类添加构造函数时出现此错误。
-
对我来说,问题是我需要为服务行为添加一个名称,然后将该行为分配给服务以使 SOAP 正常工作,尽管没有它,其余的工作仍然有效。在我的情况下,soap 需要元数据交换
标签: wcf