【发布时间】:2010-01-14 08:32:44
【问题描述】:
我有一个简单的控制台应用程序,它作为 WCF 服务主机运行。使用 bsicHttpBinding。 当我尝试在我的客户端(另一个控制台应用程序)中获取服务引用时,我收到此错误
"下载 http://localhost:9999/TS 时出错。 请求失败,HTTP 状态为 400:错误请求。 元数据包含无法解析的引用:“http://localhost:9999/TS”。 内容类型应用程序/soap+xml;服务 http://localhost:9999/TS 不支持 charset=utf-8。客户端和服务绑定可能不匹配。 远程服务器返回错误:(415)无法处理消息,因为内容类型'application/soap+xml; charset=utf-8' 不是预期的类型 'text/xml;字符集=utf-8'.. 如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用。"
请提供任何指示。
App.config:
<configuration>
<system.serviceModel>
<services>
<service
name="TimeServiceLibrary.TimeService"
behaviorConfiguration="TSConfig">
<endpoint address="localhost:9999/TS"
binding="basicHttpBinding"
contract="TimeServiceLibrary.ITime">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TSConfig">
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
【问题讨论】: