WCF分布式开发常见错误解决(9):无终结点监听,There was no endpoint listening at
当我们添加服务元数据地址,查找元数据服务,进行反序列操作。会出现这样的错误:无终结点监听Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:9004/mex'.
There was no endpoint listening at net.tcp://localhost:9004/mex that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
If the service is defined in the current solution, try building the solution and adding the service reference again.如图所示:
可能原因:此错误是由于
1.元数据服务地址错误导致。
2.托管宿主没有启动。
解决办法:
1.配置元数据交换终结点,如<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
2.运行托管宿主;
3.输入对应的元数据交换终结点地址即可。注意例子里是http元数据交换协议,我们查询元数据服务的时候一定要注意绑定协议。
备注:skypan发现的这个错误,表示感谢,这里特定整理出来供大家参考。
4.此外如果部署IIS托管WCF服务,很可能出现这样的错误。主要是服务地址在部署以后路径导致地址错误:有网友在WCF中文论坛讨论了此问题。大家可以参考:
CSQ333: 请教在开发的时候都OK的,部署到WIN2003上后就出现错误了:
http://social.msdn.microsoft.com/Forums/en-US/wcfzhchs/thread/bf879ce5-aff5-484f-b6ed-65ee6a0c69aa。
NineTyNine_LiPei:客户端调用服务的终结点地址的路径问题的测试(IIS托管WCF服务程序):
http://social.msdn.microsoft.com/Forums/en-US/wcfzhchs/thread/4ce24ea1-ece5-423d-b07b-a39692895b72