【发布时间】:2013-05-15 12:14:04
【问题描述】:
我有一个简单的 Web 服务 (WCF) 托管在 Windows 服务 (Selfhost) 中。服务的声明如下所示:
<service behaviorConfiguration="MyApp.ServiceImplementation.MyAppIntegration_Behavior" name="MyApp.ServiceImplementation.MyAppIntegration">
<endpoint binding="basicHttpBinding" bindingConfiguration="BasicMyAppIntegration" bindingNamespace="MyApp.ServiceImplementation" contract="MyApp.ServiceContracts.IMyAppIntegration"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8008/MyAppServiceutv/Integration"/>
</baseAddresses>
</host>
</service>
我可以用这个 URL 浏览 WSDL:
http://localhost:8008/MyAppServiceutv/Integration?wsdl
在 Visual Studio 2012 中添加服务引用时出现此异常:
例外
文档已被理解,但无法处理。
- WSDL 文档包含无法解析的链接。
- 下载“
http://localhost:8008/MyAppServiceutv/Integration?xsd=xsd0”时出错。 - 无法连接到远程服务器
元数据包含无法解析的引用:“http://MyComputer:8008/MyAppServiceutv/Integration?wsdl”。
内容类型应用程序/soap+xml;服务 http://MyComputer:8008/MyAppServiceutv/Integration?wsdl 不支持 charset=utf-8。客户端和服务绑定可能不匹配。
远程服务器返回错误:(415)无法处理消息,因为内容类型'application/soap+xml; charset=utf-8' 不是预期的类型 'text/xml;字符集=utf-8'..
如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用。
迁移到开发环境
将服务移至开发计算机时,一切正常吗?为什么我会在一个环境中遇到上述问题?这可能是由于严格的安全限制造成的吗?
【问题讨论】:
-
服务是否在 Cassini 中运行?如果是这样,它不能从不同的机器调用,你需要将它发布到 iis
-
否 服务作为 Windows 服务自托管。在开发计算机上生成代理没有问题,但是当将其全部移动到这个更安全的环境时,它就不行了吗?
-
8008 端口是否配置为接受流量?您可能需要从 VS.NET 2010 命令提示符使用此命令,如下所示:netsh http add urlacl url=http://+:8008/user=\everyone.
-
@Rajesh 这可能是它,你的意思是我可以通过键入该行直接从 Visual Studio 2010 GUI 设置正确的权限吗?我会试试这个。
-
在命令提示符下完成
标签: c# wcf web-services proxy wsdl