我有一个 WCF 服务,它的配置文件如下所示:
<system.serviceModel>
<services>
<service name="WCFService.ServiceClass" behaviorConfiguration="metaDataSupport">
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/WCFService"/>
<add baseAddress="net.tcp://localhost:8100/WCFService"/>
<add baseAddress="http://localhost:8101/WCFService"/>
</baseAddresses>
</host>
<endpoint address="tcpmex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
<endpoint address="namedpipemex"
binding="mexNamedPipeBinding"
contract="IMetadataExchange" />
<endpoint address=""
binding="wsHttpBinding"
contract="WCFService.IServiceClass" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metaDataSupport">
<serviceMetadata httpGetEnabled="false" httpGetUrl="" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
我这里有 3 种类型的绑定:NamedPipeBinding、TcpBinding 和 wsHttpBinding。
我可以在以下位置添加带有元数据的引用
net.tcp://localhost:8100/WCFService/tcpmex
net.pipe://localhost/WCFService/namedpipemex
我已经为行为中的服务禁用了 httpGet。
添加了服务引用,但在客户端具有以下配置:
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSHttpBinding_IServiceClass" />
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8101/WCFService" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IServiceClass" contract="TCP.IServiceClass"
name="WSHttpBinding_IServiceClass">
</endpoint>
</client>
</system.serviceModel>
但是由于我使用 TCP Binding 端点添加了一个引用,所以我期望:
地址=net.tcp://localhost:8100/WCFService
和绑定="mexTcpBinding"
该服务正在运行,但我想知道,这里发生了什么。这是什么原因。是由于 baseAddress 还是对 wsHttpBinding 的某些偏好?
想法受到赞赏。
谢谢。