4

我有一个简单的 .NET 4 WCF 服务,我在 IIS7.5 上本地托管。最初我使用它托管httpBinding它工作正常。然后我将它切换到netTcpBinding,在web.config相应地更改文件后也可以正常工作。但是今天它决定停止工作。我根本无法使用测试客户端连接到服务,得到:

URI: net.tcp://localhost/case/service.svc/mex Metadata contains a reference that cannot be resolved: 'net.tcp://localhost/case/service.svc/mex'. The message could not be dispatched because the service at the endpoint address 'net.tcp://localhost/case/service.svc/mex' is unavailable for the protocol of the address.

我检查了(仍然)安装了非http激活服务;net tcp 监听服务正在运行;net.tcp 在站点的启用协议列表中;我跑了servicemodelreg.exe -ia;我也重新跑了aspnet_regiis.exe -i;最后我检查了网站上的 net.tcp 绑定。

如果我运行,netstat我可以看到端口上正在侦听某些东西,但我无法连接到它。

这让我发疯,因为今天早上它工作得很好(就像上周一样),但现在不是了。

编辑:如果我在 IE 中访问该服务,那么我可以看到它抛出以下异常:

Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].

但是查看web.config文件似乎并非如此:

<services>
  <service behaviorConfiguration="ServiceBehavior" name="[REMOVED].[REMOVED]">
    <endpoint binding="netTcpBinding" bindingConfiguration="PortSharingBinding" contract="[REMOVED].[REMOVED]" />
    <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
  </service>
</services>

<bindings>
  <netTcpBinding>
    <binding name="PortSharingBinding" portSharingEnabled="true">
      <security mode="None"/>
    </binding>
    <binding name="mexTcpBinding" portSharingEnabled="true">
      <security mode="None" />
    </binding>
  </netTcpBinding>
</bindings>
4

2 回答 2

7

好的,终于解决了。我在站点级别启用了 net.tcp 协议,但在应用程序级别没有启用它。我想它一定是以前,我想我可能会在之前更改项目名称后创建一个新应用程序,显然忘记在应用程序上设置协议 - 哦!

因此,在 IIS 上托管 WCF net.tcp 服务的最终清单是:

  1. 确保已安装 WCF 非 HTTP 激活服务
  2. 确保Net.Tcp Listener服务和Net.Tcp Port Sharing服务都在运行
  3. 将 net.tcp 添加到站点和应用程序的启用协议(要从 IIS 管理器访问高级设置选项,您必须存在 http 绑定)
  4. 运行servicemodelreg.exe -ia以向 IIS 注册 WCF 元素
  5. 运行aspnet_regiis.exe -i以确保使用 IIS 正确设置 .NET
  6. 将 net.tcp 绑定添加到站点
于 2011-08-01T14:19:14.690 回答
0

您是否检查过端口共享已启用?

请参阅http://msdn.microsoft.com/en-us/library/ms734772.aspx

编辑 - 对于 WAS,还需要另一项服务:

除了NetTcpPortSharing服务NetTcpActivator也需要...

请参阅http://msdn.microsoft.com/en-us/magazine/cc163357.aspx

于 2011-08-01T13:23:20.943 回答