Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

IClientMessageInspector Interface

Defines a message inspector object that can be added to the MessageInspectors collection to view or modify messages.

Namespace:  System.ServiceModel.Dispatcher
Assemblies:   System.ServiceModel.Primitives (in System.ServiceModel.Primitives.dll)
  System.ServiceModel (in System.ServiceModel.dll)

type IClientMessageInspector =  interface end

The IClientMessageInspector type exposes the following members.

  NameDescription
Public methodAfterReceiveReplyEnables inspection or modification of a message after a reply message is received but prior to passing it back to the client application.
Public methodBeforeSendRequestEnables inspection or modification of a message before a request message is sent to a service.
Top

Implement the IClientMessageInspector interface and add it to the MessageInspectors collection to inspect or modify messages as they pass through a WCF client object. For details, see ClientRuntime.

The following code example shows an implementation that writes strings to the console when the implementation is called.

No code example is currently available or this language may not be supported.

The following code example shows how to use an System.ServiceModel.Description.IEndpointBehavior to insert the client message inspector in the client endpoint.

No code example is currently available or this language may not be supported.

Finally, the following code example shows how to modify the client configuration file to use the endpoint behavior with a particular endpoint.

No code example is currently available or this language may not be supported.
  <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>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft