I am a bit confused on what exactly I am instantiating with the WCF ServiceHost
when I have multiple endpoint contracts that I am adding to it.
The instantiation has included a typeof argument - which seems to be the contract and is so in everything I have read and done. However when I come across adding additional contracts - this is where my confusion about it is.
ServiceHost shost = new ServiceHost(typeof(MyService), NetTcpBinding, xyz);
So let's say I have several contracts - ProductService, BatchService, CustomerService these are endpoint contracts that each have an interface. Let's keep it simple there is an Add Method and a Get Method in each of these contracts.
I can then add these endpoints which are contracts to the ServiceHost
..
shost.Endpoint.Add(ProductService);
shost.Endpoint.Add(BatchService);
shost.Endpoint.Add(CustomerService);
This is my confusion if I create it with MyService
, then does MyService
need to incorporate the methods of all of my endpoint contracts or does this just pass in the first Endpoint Contract just to instantiate it and then all the additional ones are (forgive my lack of a better way of saying this) - additional services provided by the service that was instantiated with one of my endpoints ?
I have read on SO and looking here seems relevant and close - but does not give an explanation of the instantiation of the ServiceHost Run WCF ServiceHost with multiple contracts
I mean what is the point of instantiating the thing ; and then adding endpoints if you have to place all of the endpoint methods into the host contract anyway where btw you can specify namespaces for the contract as well..- that just seems so un oop .. is the answer found at the link really the viable answer (it smells WET ~ W'peat Every Thing - AKA not DRY].