我有一个简单的 .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>