Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

IParameterInspector.AfterCall Method

Called after client calls are returned and before service responses are sent.

Namespace:  System.ServiceModel.Dispatcher
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
void AfterCall(
	string operationName,
	Object[] outputs,
	Object returnValue,
	Object correlationState


Type: System.String

The name of the invoked operation.

Type: System.Object[]

Any output objects.

Type: System.Object

The return value of the operation.

Type: System.Object

Any correlation state returned from the BeforeCall method, or null.

On outbound calls from a client, the inspector is invoked before the request contents are serialized and sent to the service. The inspector is also called after the response has been deserialized but before the return values have been dispatched to the proxy method.

On inbound calls to a service, the inspector is invoked after parameters are deserialized but before they are dispatched to the service operation.

The following code example shows an IParameterInspector implementation that:

  • Writes the operation name and return value to the console after a response has been deserialized by the service or a request has been serialized by a client.

  • Writes the operation name to the console after deserializing a response on the client or after a response has been serialized on the service.

#region IParameterInspector Members
public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)
    "IParameterInspector.AfterCall called for {0} with return value {1}.", 

public object BeforeCall(string operationName, object[] inputs)
  Console.WriteLine("IParameterInspector.BeforeCall called for {0}.", operationName);
  return null;

The following code example shows how to use either System.ServiceModel.Description.IOperationBehavior, System.ServiceModel.Description.IEndpointBehavior, or System.ServiceModel.Description.IServiceBehavior to insert IParameterInspector objects.

using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Configuration;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.Text;

namespace Microsoft.WCF.Documentation
  public class InspectorInserter : BehaviorExtensionElement, IServiceBehavior, IEndpointBehavior, IOperationBehavior
    #region IServiceBehavior Members
    public void AddBindingParameters(
      ServiceDescription serviceDescription, 
      ServiceHostBase serviceHostBase, 
      System.Collections.ObjectModel.Collection<ServiceEndpoint> endpoints, 
      BindingParameterCollection bindingParameters
    { return; }

    public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
      foreach (ChannelDispatcher chDisp in serviceHostBase.ChannelDispatchers)
        foreach (EndpointDispatcher epDisp in chDisp.Endpoints)
          epDisp.DispatchRuntime.MessageInspectors.Add(new Inspector());
          foreach (DispatchOperation op in epDisp.DispatchRuntime.Operations)
            op.ParameterInspectors.Add(new Inspector());

    public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase){ return; }

    #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; }
    #region IOperationBehavior Members
    public void AddBindingParameters(
      OperationDescription operationDescription, BindingParameterCollection bindingParameters
    { return; }

    public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
      clientOperation.ParameterInspectors.Add(new Inspector());

    public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
      dispatchOperation.ParameterInspectors.Add(new Inspector());

    public void Validate(OperationDescription operationDescription){ return; }


    public override Type BehaviorType
      get { return typeof(InspectorInserter); }

    protected override object CreateBehavior()
    { return new InspectorInserter(); }

.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
© 2014 Microsoft. All rights reserved.