WCF NetTcpBinding的托管在IIS7.5停止工作 [英] WCF netTcpBinding hosted on IIS7.5 Stops Working
问题描述
我有我已经在IIS7.5本地托管简单的.NET 4 WCF服务。最初,我是有托管使用 httpBinding
这工作得很好。然后我切换到 NetTcpBinding的
,它改变了的web.config后
相应的文件也工作正常。然而今天,它已决定停止工作。使用测试客户端的所有,让我无法连接到该服务:
URI:的net.tcp://localhost/case/service.svc/mex元数据包含了一个参考无法得到解决:的net.tcp://localhost/case/service.svc/ MEX。无法调度的消息,因为在端点地址的服务。的net.tcp://localhost/case/service.svc/mex'是地址的协议无效
我已经检查了非HTTP激活服务(仍然)安装;净TCP监听服务正在运行;是的net.tcp在为网站启用的协议列表;我已经运行 servicemodelreg.exe -ia
;我也重新运行 ASPNET_REGIIS.EXE -i
;最后我已经检查了net.tcp绑定是在网站上。
如果我跑的netstat
我可以看到一些监听的端口上,但我无法连接到它。
这是我发疯,因为今天早上它工作正常(上周,因为它是),现在它只是没有。
编辑::如果我进入IE中的服务的话,我可以看到它抛出了以下异常:
找不到与绑定NetTcpBinding的端点符合计划的net.tcp的基址。已注册的基址方案是[HTTP]。
不过看在的web.config
文件似乎并没有这样的情况:
<服务>
<服务behaviorConfiguration =ServiceBehaviorNAME =[删除] [删除]>
<端点绑定=NetTcpBinding的bindingConfiguration =PortSharingBinding合同=[删除] [删除]。/>
<端点地址=MEX绑定=mexTcpBinding合同=IMetadataExchange接口/>
< /服务>
< /服务>
<绑定>
< NetTcpBinding的>
<绑定名称=PortSharingBindingportSharingEnabled =真正的>
<安全模式=无/>
< /装订>
<绑定名称=mexTcpBindingportSharingEnabled =真正的>
<安全模式=无/>
< /装订>
< / NetTcpBinding的>
< /绑定>
OK,终于解决了这个问题。我已使协议的net.tcp在网站级别,但它并没有在应用程序级别启用。我想这一定是之前,我想改变项目名称前面会后我创建了一个新的应用程序,显然忘了设置上的应用协议 - 卫生署
因此,对于托管在IIS中的WCF服务的net.tcp最终清单是:
- 确保WCF非HTTP激活服务安装
- 确保
监听器的net.tcp
服务和Net.Tcp端口共享
服务都运行 - 添加的net.tcp到启用的协议的网站和应用程序(来访问IIS管理器中的高级设置选项,则必须有一个HTTP绑定present)
- 运行
servicemodelreg.exe -ia
注册WCF元素IIS - 运行
ASPNET_REGIIS.EXE -i
来确保.NET是正确设置与IIS - 添加net.tcp绑定的网站
I have a simple .NET 4 WCF service which I have hosted locally on IIS7.5. Initially I had it hosted using httpBinding
which worked fine. Then I switched it to netTcpBinding
, which after changing the web.config
file accordingly was also working fine. However today it has decided to stop working. I cannot connect to the service using the test client at all, getting:
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.
I have checked that the non-http activation service is (still) installed; the net tcp listener service is running; net.tcp is in the list of enabled protocols for the site; I have run servicemodelreg.exe -ia
; I have also re-run aspnet_regiis.exe -i
; and finally I have checked the net.tcp binding is on the site.
If I run netstat
I can see something is listening on the port, but I cannot connect to it.
This is driving me nuts, as this morning it was working fine (as it was last week) and now it's just not.
EDIT: If I access the service in IE then I can see it's throwing the following exception:
Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
But looking in the web.config
file that doesn't seem to be the case:
<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>
OK, finally solved it. I had enabled net.tcp protocol at the site level, but it was not enabled at the application level. I guess it must have been before, and I think I might of created a new application after changing the project name earlier and obviously forgot to set the protocol on the application - doh!
So the final checklist for hosting a WCF net.tcp service on IIS is:
- Ensure the WCF Non-HTTP Activation service is installed
- Ensure the
Net.Tcp Listener
Service andNet.Tcp Port Sharing
Service are both running - Add net.tcp to the enabled protocols for the site and the application (to access the Advanced Settings option from IIS Manager you must have an http binding present)
- Run
servicemodelreg.exe -ia
to register WCF elements with IIS - Run
aspnet_regiis.exe -i
to ensure .NET is setup correctly with IIS - Add net.tcp binding to the site
这篇关于WCF NetTcpBinding的托管在IIS7.5停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!