2

我有一个服务应用程序,它具有以下 web.config 文件:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>

  <standardEndpoints>
  </standardEndpoints>
  <bindings>
  </bindings>
  <services>
  <service behaviorConfiguration="metadatabehaviour" name="WCF_Service.HistorianService">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
      contract="WCF_Service.IHistorianCollectorService" />
    <endpoint address="net.tcp://localhost:8081/mex" binding="mexTcpBinding"
      contract="IMetadataExchange" />
    <endpoint address="net.tcp://localhost:8081" binding="netTcpBinding"
      contract="WCF_Service.IHistorianCollectorService" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="metadatabehaviour">
      <serviceMetadata httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>

 <serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
 </system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
 </system.webServer>

 </configuration>

我收到以下错误:添加服务失败。服务元数据可能无法访问。确保您的服务正在运行并公开元数据。

如果我只是实现“basicHttpBinding”,我可以成功运行该服务,但是一旦我引入一个“netTcp”绑定,我就会开始收到这个错误。我已将“mex”绑定更改为“mexTcpBinding”,但错误仍然存​​在。我曾尝试切换相关属性。知道如何纠正这个错误吗?

4

2 回答 2

0

看来您实际上禁用了元数据交换:

<serviceMetadata httpGetEnabled="false" />

应该设置为真!

于 2012-09-25T19:41:21.530 回答
0

我找到了解决方案。我的 net.tcp 端口号的值为“0”。我不知道这是可能的。将其更改为 808 即可。

于 2012-09-28T11:08:12.030 回答