使用net tcp绑定托管WCF服务。错误:服务元数据可能无法访问

使用net tcp绑定托管WCF服务。错误:服务元数据可能无法访问,wcf,nettcpbinding,Wcf,Nettcpbinding,我有一个具有以下web.config文件的服务应用程序: <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <standardEndpoints> </s

我有一个具有以下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”,但错误仍然存在。
我已尝试切换相关属性。知道如何更正此错误吗?

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

<serviceMetadata httpGetEnabled="false" />


它应该设置为true

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

<serviceMetadata httpGetEnabled="false" />


它应该设置为true

我找到了解决办法。我的net.tcp端口号的值为“0”。我不知道那是可能的。把它改成808就行了。

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

如果只添加第二个net.tcp端点,您可以运行该服务吗?@LadislavMrnka-不,即使只有net.tcp端点,我也无法运行该服务。如果只添加第二个net.tcp端点,您可以运行该服务吗?@LadislavMrnka-不,即使只有net.tcp端点,我也无法运行该服务。@Vitaliy-如果我只托管HTTP端点,那将是真的。如果必须使用net.tcp绑定,则该属性必须为false。不管怎样,我仍然试图把它变成真的,但没有用。@Vitaliy-如果我只托管HTTP端点,那将是真的。如果必须使用net.tcp绑定,则该属性必须为false。不管怎么说,我还是想把它变成现实,但没有用。