For a special service testing setup we need to create multiple WCF ServiceHost
instances for the same service type, using different WCF XML configurations.
I thought of the following:
// App.config:
<services>
<!-- does not work, name must be type, but can't be type to be unique... -->
<service name="Service1">
<endpoint ...>
<host>
...
</host>
</service>
<service name="Service2">
...
</service>
</services>
// My Tests.cs:
var sh1 = new ServiceHost(typeof(Service));
var sh2 = new ServiceHost(typeof(Service));
// connect sh1 to "Service1" configuration and sh2 to "Service2" configuration
How to properly connect the ServiceHost
instances with the corresponding configuration elements? I tried the following:
sh1.Description.ConfigurationName = "Service1";
However, that does not work. It still requires me to set the service's name
attribute to the fully qualified type name of the service. But I can't, because it has to be unique...
How to host the same service type twice within a single application using WCF XML configuration?