Feb 2, 2009

WCF behaviors on callback channel

Adding behaviors to a WCF channel is widely used and easy.

For an IEndpointBehavior the following code can be used:

public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)

{

    // add endpoint behavior to service side

    endpointDispatcher.DispatchRuntime.MessageInspectors.Add(this);

}



A less documented way is to add the same behavior to the callback of a duplex channel:

public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)

{

    // add endpoint behavior to callback

    clientRuntime.CallbackDispatchRuntime.MessageInspectors.Add(this);

}



You just need to know ...

No comments:

Post a Comment