Export (0) Print
Expand All

ClientRuntime Class

Represents the insertion point for classes that extend the functionality of Windows Communication Foundation (WCF) client objects for all messages handled by a client application.

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

public sealed class ClientRuntime : ClientRuntimeCompatBase

The ClientRuntime type exposes the following members.

  NameDescription
Public propertyCallbackClientTypeGets or sets the type of the callback contract associated with a duplex client.
Public propertyCallbackDispatchRuntimeGets the dispatch run-time that dispatches service-initiated operations.
Public propertyChannelInitializersGets a collection of channel initializer objects used to customize the channel associated with a client.
Public propertySupported in .NET for Windows Store appsClientMessageInspectorsGets a collection of message inspector objects used to view or modify messages of a particular service operation.
Public propertySupported in .NET for Windows Store appsClientOperationsGets a collection of client operation objects used to attach extension objects that inspect or modify messages and behavior of a particular service operation.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsContractClientTypeGets or sets the type of the contract associated with a client.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsContractNameGets the name of the contract associated with a client.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsContractNamespaceGets the namespace of the contract associated with a client.
Public propertyInteractiveChannelInitializersGets a collection of an interactive channel initializer.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsManualAddressingGets or sets a value that indicates whether the client adds addressing headers to request-reply messages.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsMaxFaultSizeGets or sets the maximum fault size.
Public propertyMessageInspectorsGets a collection of message inspector implementations for a client.
Public propertyMessageVersionNoneFaultsEnabledGets or sets a value that indicates whether the MessageVersionNoneFaultsEnabled property is set.
Public propertyOperationsGets a collection of client operations for a client.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsOperationSelectorGets or sets an IClientOperationSelector implementation that can be used to select a ClientOperation.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsUnhandledClientOperationGets the client operation for methods that do not have a corresponding ClientOperation in the Operations collection.
Public propertyValidateMustUnderstandGets or sets a value that specifies whether the system or the application enforces SOAP MustUnderstand header processing.
Public propertySupported by Portable Class LibrarySupported in .NET for Windows Store appsViaGets or sets the transport address that is used to send messages through the client.
Top

  NameDescription
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Portable Class LibrarySupported in .NET for Windows Store appsToStringReturns a string that represents the current object. (Inherited from Object.)
Top

WCF client objects, whether an extension of ClientBase<TChannel> or of IClientChannel, are used by Windows Communication Foundation (WCF) client applications to convert method calls into outbound messages and convert incoming messages to objects and pass them to the results of client methods.

The ClientRuntime class is an extensibility point to which you can add extension objects that intercept messages and extend client behavior across all operations. Interception objects can process all messages in a particular contract, process only messages for particular operations, perform custom channel initialization, and implement other custom client application behavior. For an overview of client architecture, see Client Architecture. For more information about client programming, see Accessing Services Using a Client. For details about customizations and how to perform them, see Extending Clients.

  • The CallbackDispatchRuntime property returns the dispatch run-time object for service-initiated callback operations.

  • The OperationSelector property accepts a custom operation selector object to control the routing of client messages.

  • The ChannelInitializers property enables the addition of a channel initializer that can inspect or modify the client channel.

  • The InteractiveChannelInitializers property can be used to display a visual prompt to enable a user to select credentials prior to opening the channel.

  • The Operations property gets a collection of ClientOperation objects to which you can add custom message interceptors that provide functionality specific to the messages of that operation.

  • The ManualAddressing property enables an application to turn off some automatic addressing headers to directly control addressing.

  • The MaxFaultSize property enables the client to limit the size of fault messages that the client accepts.

  • The MessageInspectors property gets a collection of IClientMessageInspector objects to which you can add custom message interceptors for all messages traveling through a client.

  • The UnhandledClientOperation property returns the operation to which unexpected messages are passed.

  • The ValidateMustUnderstand property informs the system whether it should confirm that SOAP headers marked as MustUnderstand have, in fact, been understood.

  • The Via property sets the value of the destination of the message at the transport level to support intermediaries and other scenarios.

In addition, there are a number of other properties that retrieve the client contract information:

If the client is a duplex client, the following properties also retrieve the client callback type and runtime:

In the following code example an System.ServiceModel.Description.IEndpointBehavior inserts a System.ServiceModel.Dispatcher.IClientMessageInspector into the client runtime by adding it to the MessageInspectors property.

#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; }

The following code example shows a configuration file that loads the endpoint behavior into the client endpoint.

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft