Ezequiel Falcón
Ezequiel Falcón

Reputation: 13

Identify on which Contract was a WCF service called

Is possible to know which contract has been called in a multiple contract service? In this, case, in the constructor.

The implementing class of the service is like this:

public class Service : IContract1, IContract2
{
    public Service()
    {
        //Identify if constructor was called from IContract1 or IContract2
    }
}

Upvotes: 1

Views: 420

Answers (1)

William Xifaras
William Xifaras

Reputation: 5312

I think what you want to implement is a WCF Message Inspector. A MessageInspector is a "message filter" that can intercept and inspect the messages coming in or going out of the service layer infrastructure.

On the server, you would implement the IDispatchMessageInspector Interface.

Here is a pretty good example:

http://www.aspnet4you.com/wcf/index.php/2013/01/30/message-interception-auditing-and-logging-at-wcf-pipeline/

Upvotes: 1

Related Questions