ClientRuntime.MessageInspectors Property

 

Gets a collection of message inspector implementations for a client.

Namespace:   System.ServiceModel.Dispatcher
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public SynchronizedCollection<IClientMessageInspector> MessageInspectors { get; }

Use the MessageInspectors property to attach custom IClientMessageInspector implementations to inspect or modify all messages that flow through the client.

In the following code example an System.ServiceModel.Description.IEndpointBehavior inserts a System.ServiceModel.Dispatcher.IClientMessageInspector into the client runtime by adding it to the MessageInspectors property.

#region IEndpointBehavior Members
public void AddBindingParameters(
  ServiceEndpoint endpoint, BindingParameterCollection bindingParameters
) { return; }

public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
  clientRuntime.MessageInspectors.Add(new Inspector());
  foreach (ClientOperation op in clientRuntime.Operations)
    op.ParameterInspectors.Add(new Inspector());
}

public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
  endpointDispatcher.DispatchRuntime.MessageInspectors.Add(new Inspector());
  foreach (DispatchOperation op in endpointDispatcher.DispatchRuntime.Operations)
    op.ParameterInspectors.Add(new Inspector());
}

public void Validate(ServiceEndpoint endpoint){ return; }

The following code example shows a configuration file that loads the endpoint behavior into the client endpoint.

.NET Framework
Available since 3.0
Silverlight
Available since 4.0
Return to top
Show: