views:

20

answers:

1

I am hosting several endpoints under same service host, which implement same service contract. I need to start different business layer based on the endpoint name, so is there a way I get endpoint name inside my service implementation constructor? Basically, as a service I need to know which endpoint I was started under.

+2  A: 

You can check out the OperationContext.Current; in your service code - it contains amongst other things an EndpointDispatcher:

 OperationContext ctx = OperationContext.Current;
 EndpointDispatcher epd = ctx.EndpointDispatcher;

That endpoint dispatcher has lots of properties such as ContractName, ContractNamespace, EndpointAddress and lots more.

Check the relevant MSDN documentation for OperationContext and EndpointDispatcher for the detailed list of properties they give you.

marc_s