Export (0) Print
Expand All

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)

'Declaration
Sub AfterCall ( _
	operationName As String, _
	outputs As Object(), _
	returnValue As Object, _
	correlationState As Object _
)

Parameters

operationName
Type: System.String

The name of the invoked operation.

outputs
Type: System.Object()

Any output objects.

returnValue
Type: System.Object

The return value of the operation.

correlationState
Type: System.Object

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

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 Sub AfterCall(ByVal operationName As String, ByVal outputs() As Object, ByVal returnValue As Object, _
                             ByVal correlationState As Object) Implements IParameterInspector.AfterCall
            Console.WriteLine("IParameterInspector.AfterCall called for {0} with return value {1}.", _
                              operationName, returnValue.ToString())
        End Sub 

        Public Function BeforeCall(ByVal operationName As String, ByVal inputs() As Object) As Object Implements _
        IParameterInspector.BeforeCall
            Console.WriteLine("IParameterInspector.BeforeCall called for {0}.", operationName)
            Return Nothing 
        End Function

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.

Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports System.ServiceModel.Configuration
Imports System.ServiceModel.Description
Imports System.ServiceModel.Dispatcher
Imports System.Text

Namespace Microsoft.WCF.Documentation
  Public Class InspectorInserter
	  Inherits BehaviorExtensionElement
	  Implements IServiceBehavior, IEndpointBehavior, IOperationBehavior
	#Region "IServiceBehavior Members" 
        Public Sub AddBindingParameters(ByVal serviceDescription As ServiceDescription, _
                       ByVal serviceHostBase As ServiceHostBase, ByVal endpoints As  _
                       System.Collections.ObjectModel.Collection(Of ServiceEndpoint), _
                       ByVal bindingParameters As BindingParameterCollection) Implements IServiceBehavior.AddBindingParameters
            Return 
        End Sub 

        Public Sub ApplyDispatchBehavior(ByVal serviceDescription As ServiceDescription, _
                                         ByVal serviceHostBase As ServiceHostBase) Implements _
                                         IServiceBehavior.ApplyDispatchBehavior
            For Each chDisp As ChannelDispatcher In serviceHostBase.ChannelDispatchers
                For Each epDisp As EndpointDispatcher In chDisp.Endpoints
                    epDisp.DispatchRuntime.MessageInspectors.Add(New Inspector())
                    For Each op As DispatchOperation In epDisp.DispatchRuntime.Operations
                        op.ParameterInspectors.Add(New Inspector())
                    Next op
                Next epDisp
            Next chDisp
        End Sub 

        Public Sub Validate(ByVal serviceDescription As ServiceDescription, ByVal serviceHostBase As ServiceHostBase) _
        Implements IServiceBehavior.Validate
            Return 
        End Sub

	#End Region
	#Region "IEndpointBehavior Members" 
        Public Sub AddBindingParameters(ByVal endpoint As ServiceEndpoint, ByVal bindingParameters _
                                        As BindingParameterCollection) Implements IEndpointBehavior.AddBindingParameters
            Return 
        End Sub 

        Public Sub ApplyClientBehavior(ByVal endpoint As ServiceEndpoint, ByVal clientRuntime As ClientRuntime) _
        Implements IEndpointBehavior.ApplyClientBehavior
            clientRuntime.MessageInspectors.Add(New Inspector())
            For Each op As ClientOperation In clientRuntime.Operations
                op.ParameterInspectors.Add(New Inspector())
            Next op
        End Sub 

        Public Sub ApplyDispatchBehavior(ByVal endpoint As ServiceEndpoint, ByVal endpointDispatcher As  _
                                         EndpointDispatcher) Implements IEndpointBehavior.ApplyDispatchBehavior
            endpointDispatcher.DispatchRuntime.MessageInspectors.Add(New Inspector())
            For Each op As DispatchOperation In endpointDispatcher.DispatchRuntime.Operations
                op.ParameterInspectors.Add(New Inspector())
            Next op
        End Sub 

	Public Sub Validate(ByVal endpoint As ServiceEndpoint) Implements IEndpointBehavior.Validate
		Return 
	End Sub
	#End Region
	#Region "IOperationBehavior Members" 
        Public Sub AddBindingParameters(ByVal operationDescription As OperationDescription, _
                                        ByVal bindingParameters As BindingParameterCollection) Implements _
                                        IOperationBehavior.AddBindingParameters
            Return 
        End Sub 

        Public Sub ApplyClientBehavior(ByVal operationDescription As OperationDescription, ByVal _
                                       clientOperation As ClientOperation) Implements IOperationBehavior.ApplyClientBehavior
            clientOperation.ParameterInspectors.Add(New Inspector())
        End Sub 

        Public Sub ApplyDispatchBehavior(ByVal operationDescription As OperationDescription, ByVal dispatchOperation As  _
                                         DispatchOperation) Implements IOperationBehavior.ApplyDispatchBehavior
            dispatchOperation.ParameterInspectors.Add(New Inspector())
        End Sub 

	Public Sub Validate(ByVal operationDescription As OperationDescription) Implements IOperationBehavior.Validate
		Return 
	End Sub

	#End Region

	Public Overrides ReadOnly Property BehaviorType() As Type
	  Get 
		  Return GetType(InspectorInserter)
	  End Get 
	End Property 

	Protected Overrides Function CreateBehavior() As Object 
		Return New InspectorInserter()
	End Function 
  End Class 
End Namespace

.NET Framework

Supported in: 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 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