I wanted a discoverable service that would listen on all interfaces and publish discovery announcements for each interface. I was hoping to be able to eventually just configure this in the config file using tcp://0.0.0.0:0/blah as the service endpoint. But when I run the code below, the announcements that it sends out use tcp://0.0.0.0:0/blah as the EndpointAddress which is useless to clients.
I want to receive announcements for every endpoint it derived from tcp://0.0.0.0:0/blah and I would prefer to use a config file and not a programmatic service host setup like below. Any ideas for a workaround?
[TestFixtureSetUp]
public void SetUp()
{
service1 = new MyContract();
EndpointDiscoveryBehavior discoveryBehavior = new EndpointDiscoveryBehavior();
ServiceDiscoveryBehavior serviceDiscoveryBehavior = new ServiceDiscoveryBehavior(discoveryUri);
serviceDiscoveryBehavior.AnnouncementEndpoints.Add(new UdpAnnouncementEndpoint(announcementUri));
serviceHost1 = new ServiceHost(service1,
new Uri[] {new Uri("net.pipe://localhost"), new Uri("net.tcp://0.0.0.0:0")});
ServiceEndpoint localEndpoint1 = serviceHost1.AddServiceEndpoint(typeof (IContract),
new NetNamedPipeBinding(),
"/Pipe");
ServiceEndpoint localEndpoint2 = serviceHost1.AddServiceEndpoint(typeof (IContract),
new NetTcpBinding(),
"/Tcp");
localEndpoint2.Behaviors.Add(discoveryBehavior);
serviceHost1.Description.Behaviors.Add(serviceDiscoveryBehavior);
serviceHost1.AddServiceEndpoint(new UdpDiscoveryEndpoint(discoveryUri));
serviceHost1.Open();
}