Note: Cross posted from Sajay.
Permalink

When we need to modify or see the message before its sent or after its received, we generally can use a Message inspector. However sometimes we want to be a bit more granular. One such requirement was to perform some operations for 2-way calls and a different set of operations for one way calls. For this you can probably use extensibility points like the IParameterInspector and attach the required inspector to those appropriate operations.

 

public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
    foreach (ClientOperation operation in clientRuntime.Operations)
    {
        if (!operation.IsOneWay)
        {
            operation.ParameterInspectors.Add(new TwoWayBehavior());
        }
        else
        {
            operation.ParameterInspectors.Add(new OneWayBehavior());
        }
    }
}

Here is the source.(3.13 kb)