Running ServiceHost with one contract works like this:
servicehost = new ServiceHost(typeof(MyService1)); servicehost.AddServiceEndpoint(typeof(IMyService1), new NetTcpBinding(), "net.tcp://127.0.0.1:800/MyApp/MyService1"); servicehost.Open();
Now I would like to add a second (third, fourth, ...) contract. My first assumption was to simply add more endpoints, for example:
servicehost = new ServiceHost(typeof(MyService1)); servicehost.AddServiceEndpoint(typeof(IMyService1), new NetTcpBinding(), "net.tcp://127.0.0.1:800/MyApp/MyService1"); servicehost.AddServiceEndpoint(typeof(IMyService2), new NetTcpBinding(), "net.tcp://127.0.0.1:800/MyApp/MyService2"); servicehost.Open();
But of course, this will not work, since when creating the ServiceHost I can either pass MyService1 as a parameter or MyService2 - so I can add many endpoints to my service, but everyone should use the same contract, since I only can provide one implementation?
I feel like I'm missing the point. Of course, there must be some way to ensure implementation for each final contract, the contract that I add, or not?
wcf self-hosting
Sam Dec 02 '08 at 16:04 2008-12-02 16:04
source share