[英]Generation of proxy works fine in one environment but not in the other?
我在Windows Service(Selfhost)中托管了一个简单的Webserivce(WCF)。 服务的声明如下所示:
<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中添加服务引用时,出现此异常:
例外
该文档已被理解,但无法处理。
http://localhost:8008/MyAppServiceutv/Integration?xsd=xsd0
'时http://localhost:8008/MyAppServiceutv/Integration?xsd=xsd0
。 元数据包含无法解析的引用:' http://MyComputer:8008/MyAppServiceutv/Integration?wsdl
'。 内容类型application / soap + xml; 服务http://MyComputer:8008/MyAppServiceutv/Integration?wsdl
不支持charset = utf-8。 客户端和服务绑定可能不匹配。 远程服务器返回错误:(415)由于内容类型为'application / soap + xml,因此无法处理该消息; charset = utf-8'不是预期的类型'text / xml; charset = utf-8'。如果服务在当前解决方案中定义,请尝试构建解决方案并再次添加服务引用。
迁移到开发环境
将服务移至开发计算机时,一切工作正常吗? 为什么在一个环境中谁会遇到上述问题? 这可能是由于强大的安全限制所致吗?
听起来您的VS2012实例已从服务主机关闭。 尝试像这样更改您的配置...
<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://{my fully qualified domain name}:8008/MyAppServiceutv/Integration"/>
</baseAddresses>
</host>
</service>
好的。 现在,我已经确认了问题……是一个解释。 .net 4.0或更低版本WCF会生成多文件WSDL文件。 基本WSDL文件链接到各种文件。 WDSL文件中的链接使用绝对URI(而不是相对URI)链接到其他文件。 因此,当您的Visual Studio尝试查找其他WDSL文件时,它将无法在“ localhost”上找到它。
使用.net 4.5,WCF可以生成“单文件WSDL”,这也可以解决您的问题。 但是总的来说,我认为在处理WSDL代理生成时WCF 4.0已损坏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.