Multiple interfaces from a single WCF service?

The following looks closer to the original goal and doesn't involve one large interface...

Multiple Endpoints at a Single ListenUri: http://msdn.microsoft.com/en-us/library/aa395210.aspx


The sample linked to above explains that it's possible to have multiple endpoints registered at the same physical address (listenUri), each implementing a different interface (contract), e.g.:

<endpoint address="urn:Stuff"
        binding="wsHttpBinding"
        contract="Microsoft.ServiceModel.Samples.ICalculator" 
        listenUri="http://localhost/servicemodelsamples/service.svc" />
<endpoint address="urn:Stuff"
        binding="wsHttpBinding"
        contract="Microsoft.ServiceModel.Samples.IEcho" 
        listenUri="http://localhost/servicemodelsamples/service.svc" />
<endpoint address="urn:OtherEcho"
        binding="wsHttpBinding"
        contract="Microsoft.ServiceModel.Samples.IEcho" 
        listenUri="http://localhost/servicemodelsamples/service.svc" />

This is possible because incoming messages are routed to the appropriate endpoint based on a combination of address and contract filters.


First you need to be clear what a service is. Do you mean a single endpoint, or multiple endpoints in the same host?

Assuming you mean a single endpoint, then yes, but with a little work. An endpoint can only implement a single interface; so what you need to do is combine all the interfaces you want to implement into a single interface

public interface IMyInterface : IInterface1, IInterface2

and then implement them all inside your implementation class. What you cannot do is have multiple interfaces and multiple implementations magically merge into a single endpoint.