Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
ClientRuntime Class
 MessageInspectors Property

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
ClientRuntime..::.MessageInspectors Property

Gets a collection of message inspector implementations for a client.

Namespace:  System.ServiceModel.Dispatcher
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
Visual Basic (Declaration)
Public ReadOnly Property MessageInspectors As SynchronizedCollection(Of IClientMessageInspector)
Visual Basic (Usage)
Dim instance As ClientRuntime
Dim value As SynchronizedCollection(Of IClientMessageInspector)

value = instance.MessageInspectors
C#
public SynchronizedCollection<IClientMessageInspector> MessageInspectors { get; }
Visual C++
public:
property SynchronizedCollection<IClientMessageInspector^>^ MessageInspectors {
    SynchronizedCollection<IClientMessageInspector^>^ get ();
}
JScript
public function get MessageInspectors () : SynchronizedCollection<IClientMessageInspector>

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.

C#
#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.

  <client>
      <endpoint 
        address="http://localhost:8080/SampleService" 
        behaviorConfiguration="clientInspectorsAdded" 
        binding="wsHttpBinding"
        bindingConfiguration="WSHttpBinding_ISampleService" 
        contract="ISampleService"
        name="WSHttpBinding_ISampleService"
      >
      </endpoint>
  </client>
<behaviors>
  <endpointBehaviors>
    <behavior name="clientInspectorsAdded">
      <clientInterceptors />
    </behavior>
  </endpointBehaviors>
</behaviors>
<extensions>
  <behaviorExtensions>
    <add 
      name="clientInterceptors" 
      type="Microsoft.WCF.Documentation.InspectorInserter, HostApplication, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
  />
  </behaviorExtensions>
</extensions>

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker