本文介绍了暴露的net.tcp端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有点困惑如何揭露WCF端点 我有一个TCP端点和MEX TCP端点。 <服务名称=MessageReaderService.MessageReaderService> <端点名称=NetTcpReaderService地址=ReaderService结合=NetTcpBinding的bindingConfiguration =合同=Contracts.IMessageReaderService/> <端点名称=netTcpMex地址=MEX结合=mexTcpBindingbindingConfiguration =合同=IMetadataExchange接口/> <主机> < baseAddresses> <添加baseAddress =的net.tcp://本地主机:8082/> < / baseAddresses> < /主机> < /服务> 当我尝试在服务主机我得到下面的异常运行此: So I conclude from this error that I need to add a service behavior to expose metadata.So I added the behavior :<behavior name="ServiceBehavior"> <serviceMetadata httpGetEnabled="true"/> </behavior> but then I get a different error :So now I have to actually add another endpoint (http) to expose the metadata over mexhttpbinding ?is there a simple way to expose the endpoint over tcp ? 解决方案 Two things:(1) once you've defined the service behavior, you of course must also apply it to the service!<service name="MessageReaderService.MessageReaderService" behaviorConfiguration="ServiceBehavior">(2) you don't need an HTTP endpoint - you don't need to have an HTTP URL - just define this service behavior like this:<behavior name="ServiceBehavior"> <serviceMetadata /></behavior> Your metadata is now available over a mexTcpBinding endpoint - you cannot browse to it using HTTP, but a client can definitely connect to it and use it!You can verify this by using the WCF Test Client and going to either net.tcp://localhost:8082 (the base address)ornet.tcp://localhost:8082/mex (the mex address)in both cases, the WCF Test Client should now find your service and be able to discover its capabilities. 这篇关于暴露的net.tcp端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-11 13:08