Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

IClientMessageInspector::BeforeSendRequest Method

Enables inspection or modification of a message before a request message is sent to a service.

Namespace:  System.ServiceModel.Dispatcher
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
Object^ BeforeSendRequest(
	Message^% request, 
	IClientChannel^ channel
)

Parameters

request
Type: System.ServiceModel.Channels::Message%

The message to be sent to the service.

channel
Type: System.ServiceModel::IClientChannel

The WCF client object channel.

Return Value

Type: System::Object
The object that is returned as the correlationState argument of the AfterReceiveReply method. This is nullptr if no correlation state is used.
The best practice is to make this a System::Guid to ensure that no two correlationState objects are the same.

Implement the BeforeSendRequest to inspect or modify a request message before it is sent.

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.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Store apps

Supported in: Windows 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.