WCF发布错误:元数据包含无法解析的引用:

Fun*_*nky 5 iis wcf publish web-services

我有一个WCF Web服务,我试图发布到IIS.我可以查看wsdl,但无法通过"添加服务引用"菜单在Visual Studio 2010中添加服务.我收到以下错误:

Metadata contains a reference that cannot be resolved: 'http://localhost:4567/Service.svc?wsdl'.
The WSDL document contains links that could not be resolved.
There was an error downloading 'http://localhost:4567/Service.svc?xsd=xsd0'.
The underlying connection was closed: An unexpected error occurred on a receive.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host
Metadata contains a reference that cannot be resolved: 'http://localhost:4567/Service.svc'.
Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:4567/Service.svc.  The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.
Run Code Online (Sandbox Code Playgroud)

我在本地工作很好,但如果发布到IIS则不行.

有谁知道导致这个问题的原因是什么?这是我的web.config,我是WCF的新手,所以可能错过了一些东西,谢谢:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <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 faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  <connectionStrings>

  </connectionStrings>
</configuration>
Run Code Online (Sandbox Code Playgroud)

Mob*_*ble 7

真的希望微软能够提供更好的诊断,以便在构建或运行时为我们提供有关WCF配置错误的更多有针对性的信息 - 我不关心哪些,但多年来浪费了这么多小时的开发时间是不真实的.

</rant>
Run Code Online (Sandbox Code Playgroud)

对我来说,这个荒谬的通用错误的原因是:

<endpoint address="mexTcp" binding="mexTcpBinding" contract="IMetadataExchange"/>
Run Code Online (Sandbox Code Playgroud)

应该是这样的:

<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
Run Code Online (Sandbox Code Playgroud)

两个小时的放屁试图启用Net.Tcp,以便在IDE中轻松突出显示的内容.两个小时!!!

  • 我赞成,因为你使用了"fart-arsing"这个短语. (3认同)
  • 只有两个小时? (2认同)

小智 2

在MSDN 论坛查看答案

当您定义 net tcp 协议时,您需要确保使用IMetadataExchange端点合同中定义的合同。为此的服务行为也需要包含该<serviceMetadata />标签。据我了解,如果您想在 VS 中托管和生成代理/发现,这几乎是您的配置的样板代码。

<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
Run Code Online (Sandbox Code Playgroud)

  • @sundog ...从您最初质量糟糕的答案中,现在已将其编辑为合理的答案。StackOverflow 社区不赞成仅提供链接的答案,因此您应该始终努力提供答案以及从链接页面获取的附加信息,如上所示。有关如何改进答案的更多信息,请参阅帮助中心的[如何写出好的答案?](http://stackoverflow.com/help/how-to-answer) 页面。 (3认同)