以下两种情况有什么区别:
配置一:
<service name="WcfService1.Service1" behaviorConfiguration="MyServiceTypeBehaviors">
<host>
<baseAddresses>
<add baseAddress="net.tcp://127.0.0.1:808/" />
</baseAddresses>
</host>
<endpoint address="service"
binding="netTcpBinding"
bindingConfiguration="MainBinding"
bindingName="MainBinding"
name="DefaultEndpoint"
contract="WcfService1.IService1" />
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
</service>
配置二:
<service name="WcfService1.Service1" behaviorConfiguration="MyServiceTypeBehaviors">
<host>
<baseAddresses>
<add baseAddress="net.tcp://127.0.0.1:808/service" />
</baseAddresses>
</host>
<endpoint address="net.tcp://127.0.0.1:808/service"
binding="netTcpBinding"
bindingConfiguration="MainBinding"
bindingName="MainBinding"
name="DefaultEndpoint"
contract="WcfService1.IService1" />
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
</service>
我的理解是在任何一种情况下,基地址+端点地址都解析为相同的绝对地址
但是为什么我在配置 2上收到错误:“没有端点正在监听 net.tcp://127.0.0.1:808/
但配置 1 运行服务没有任何错误!!!
编辑1:
工作配置:
<host>
<baseAddresses>
<add baseAddress="net.tcp://127.0.0.1:808/" />
</baseAddresses>
</host>
<endpoint address="service"
binding="netTcpBinding"
bindingConfiguration="MainBinding"
bindingName="MainBinding"
name="DefaultEndpoint"
contract="WcfService1.IService1" />
非工作配置:
<host>
<!--
<baseAddresses>
<add baseAddress="" />
</baseAddresses>
-->
</host>
<endpoint address="net.tcp://127.0.0.1:808/service"
binding="netTcpBinding"
bindingConfiguration="MainBinding"
bindingName="MainBinding"
name="DefaultEndpoint"
contract="WcfService1.IService1" />
<endpoint address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
在这种情况下,我删除了基地址并提供了完整的服务地址(没有 .svc 路径),但收到了套接字超时错误。在这种情况下有什么问题?未定义基地址时,端点地址是否总是需要带有 .svc 的完整地址?如果是这样,背后的原因可能是什么?