要走的路是创建一个包含 serviceDiscovery 元素的默认服务行为:
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceDiscovery>
<announcementEndpoints>
<endpoint
name="MyAnnouncementEndpoint"
kind="announcementEndpoint"
address="net.tcp://localhost/My.ServiceLocator/DiscoveryProxy.svc"
bindingConfiguration ="NetTcpBindingConfiguration"
binding="netTcpBinding"/>
</announcementEndpoints>
</serviceDiscovery>
</behavior>
</serviceBehaviors>
</behaviors>
这样,您的所有服务都将使用此默认行为,即使您未明确声明的服务也是如此。