Export (0) Print
Expand All

IDispatchMessageInspector::AfterReceiveRequest Method

Called after an inbound message has been received but before the message is dispatched to the intended operation.

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

Object^ AfterReceiveRequest(
	Message^% request, 
	IClientChannel^ channel, 
	InstanceContext^ instanceContext
)

Parameters

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

The request message.

channel
Type: System.ServiceModel::IClientChannel

The incoming channel.

instanceContext
Type: System.ServiceModel::InstanceContext

The current service instance.

Return Value

Type: System::Object
The object used to correlate state. This object is passed back in the BeforeSendReply method.

Use the AfterReceiveRequest method to inspect or modify the incoming message, the client channel that provided it, and the current service instance. The return value can be any object that you want to use for correlation purposes; it is returned to you as the correlationState parameter in the BeforeSendReply method.

Important noteImportant

You cannot use the body of the message unless you buffer the entire message and make a copy. If you do this, you must make two copies of the message: one to inspect, and the other to overwrite the request parameter.

The following code example shows a basic IDispatchMessageInspector that writes a string to the console when it is invoked.

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

The following code example shows the implementation of an IServiceBehavior that adds the Inspector IDispatchMessageInspector to the DispatchRuntime::MessageInspectors collection.

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

The following code example shows the use of an application configuration file to load the service behavior that inserts the Inspector IDispatchMessageInspector.

No code example is currently available or this language may not be supported.
<configuration>
  <system.serviceModel>
    <services>
      <service 
        name="Microsoft.WCF.Documentation.SampleService"
        behaviorConfiguration="inspectorBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/SampleService" />
          </baseAddresses>
        </host>
        <endpoint
          address=""
          binding="wsHttpBinding"
          contract="Microsoft.WCF.Documentation.ISampleService"
        />

      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="inspectorBehavior">
          <serviceInspectors />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <extensions>
      <behaviorExtensions>
        <add 
          name="serviceInspectors" 
          type="Microsoft.WCF.Documentation.InspectorInserter, HostApplication, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
        />
      </behaviorExtensions>
    </extensions>
  </system.serviceModel>
</configuration>

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.

Show:
© 2014 Microsoft