I Implement IDispatchMessageInspector.AfterReciveRequest Then I configure like this:
I found it much easier to attach my IDispatchMessageInspector implementation using an IServiceBehavior implementation that also extends Attribute. Then in the ApplyDispatchBehavior method, attach your message inspector to all the all of the endpoints in all of the channels.
This article helped me greatly.
Example code:
public class MyServiceBehavior : Attribute, IServiceBehavior
{
public void ApplyDispatchBehavior( ServiceDescription serviceDescription,
ServiceHostBase serviceHostBase )
{
foreach( ChannelDispatcher cDispatcher in serviceHostBase.ChannelDispatchers )
foreach( EndpointDispatcher eDispatcher in cDispatcher.Endpoints )
eDispatcher.DispatchRuntime.MessageInspectors.Add( new RequestAuthChecker() );
}
}
Then in the implementation of your service contract, you can just add the attribute to the class.
[ServiceBehavior( InstanceContextMode = InstanceContextMode.PerCall )]
[MyServiceBehavior]
public class ContractImplementation : IServiceContract
{