2013-05-15 38 views
0

我有一个简单的Webserivce(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”。 内容类型application/soap + xml; charset = utf-8不支持服务http://MyComputer:8008/MyAppServiceutv/Integration?wsdl。客户端和服务绑定可能不匹配。 远程服务器返回错误:(415)由于内容类型'application/soap + xml; charset = utf-8'不是预期的类型'text/xml; charset = utf-8'.. 如果服务在当前解决方案中定义,请尝试构建解决方案并再次添加服务引用。

移动到开发环境

当移动服务的开发电脑一切正常,好了?为什么我只能在一个环境中得到上述问题?这可能是由于强大的安全限制吗?

+0

服务是否在Cassini中运行?如果是这样,它不能从另一台机器调用,您需要将其发布到iis –

+0

否该服务作为Windows服务自动托管。在开发计算机上生成代理没有任何问题,但是在将它全部移到这个更安全的环境中时,它是不可行的? – Banshee

+0

端口8008被配置为接受流量吗?您可能需要使用VS.NET 2010命令提示符中的此命令,如下所示:netsh http add urlacl url = http:// +:8008/user = \ everyone。 – Rajesh

回答

0

听起来你的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被打破了。

+0

是服务在此故障环境中被放置在服务器上。你的意思是说它不可能在这台服务器上使用本地主机?为什么它在所有其他环境中工作得如此之好,但不是那个呢? – Banshee

相关问题