ClientRuntime クラス

定義

クライアント アプリケーションによって処理されるすべてのメッセージの Windows Communication Foundation (WCF) クライアント オブジェクトの機能を拡張するクラスの挿入ポイントを表します。

public ref class ClientRuntime sealed
public ref class ClientRuntime sealed : System::ServiceModel::Dispatcher::ClientRuntimeCompatBase
public sealed class ClientRuntime
public sealed class ClientRuntime : System.ServiceModel.Dispatcher.ClientRuntimeCompatBase
type ClientRuntime = class
type ClientRuntime = class
    inherit ClientRuntimeCompatBase
Public NotInheritable Class ClientRuntime
Public NotInheritable Class ClientRuntime
Inherits ClientRuntimeCompatBase
継承
ClientRuntime
継承

次のコード例では、System.ServiceModel.Description.IEndpointBehaviorSystem.ServiceModel.Dispatcher.IClientMessageInspectorMessageInspectors プロパティに追加することで、クライアント ランタイムに挿入しています。

#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 "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

つぎのコード例では、エンドポイントの動作をクライアント エンドポイントに読み込む構成ファイルを示します。

  <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>

注釈

WCF クライアント オブジェクトは、 または のIClientChannelどちらClientBase<TChannel>であっても、Windows Communication Foundation (WCF) クライアント アプリケーションによって、メソッド呼び出しを送信メッセージに変換し、受信メッセージを オブジェクトに変換し、クライアント メソッドの結果に渡すために使用されます。

ClientRuntime クラスは、メッセージを途中受信したり、すべての操作についてクライアントの動作を拡張したりする拡張オブジェクトを追加できる、拡張ポイントです。 途中受信オブジェクトには、特定のコントラクト内のすべてのメッセージを処理する、特定の操作用のメッセージだけを処理する、カスタムのチャネル初期化を実行する、その他のカスタム クライアント アプリケーションの動作を実行する、などの機能があります。 クライアント アーキテクチャの概要については、「 WCF クライアント アーキテクチャ」を参照してください。 クライアント プログラミングの詳細については、「 WCF クライアントを使用したサービスへのアクセス」を参照してください。 カスタマイズとその実行方法の詳細については、「 クライアントの拡張」を参照してください。

  • CallbackDispatchRuntime プロパティは、サービス側開始のコールバック操作用のディスパッチ ランタイム オブジェクトを返します。

  • OperationSelector プロパティは、クライアント メッセージのルーティングを制御するためのカスタム操作セレクター オブジェクトを受け取ります。

  • ChannelInitializers プロパティを使用すると、クライアント チャネルを検査または変更できるチャネル初期化子を追加できます。

  • InteractiveChannelInitializers プロパティを使用すると、チャネルを開く前にユーザーが資格情報を選択できるプロンプトを表示できます。

  • Operations プロパティは、ClientOperation オブジェクトのコレクションを取得します。このコレクションにカスタムのメッセージ インターセプターを追加すれば、その操作のメッセージに固有の機能を提供できます。

  • ManualAddressing プロパティをアプリケーションで使用すると、自動アドレス指定ヘッダーをオフにしてアドレス指定を直接制御できます。

  • MaxFaultSize プロパティを使用すると、クライアントは、受け取るエラー メッセージのサイズを制限できます。

  • MessageInspectors プロパティは、IClientMessageInspector オブジェクトのコレクションを取得します。このコレクションには、クライアント経由のすべてのメッセージに対応するカスタム メッセージ インターセプターを追加できます。

  • UnhandledClientOperation プロパティは、予期しないメッセージが渡された操作を返します。

  • ValidateMustUnderstand プロパティは、MustUnderstand としてマークされた SOAP ヘッダーが間違いなく理解されたことを確認する必要があるかどうかをシステムに通知します。

  • Via プロパティは、トランスポート レベルでメッセージの送信先の値を設定して、メッセージの中継者やその他のシナリオをサポートします。

また、クライアント コントラクト情報を取得するその他のプロパティも多数用意されています。

クライアントが双方向クライアントの場合は、次のプロパティもクライアント コールバックの型とランタイムを取得します。

プロパティ

CallbackClientType

双方向クライアントに関連付けられたコールバック コントラクトの型を取得または設定します。

CallbackDispatchRuntime

サービスが開始した操作をディスパッチするディスパッチ ランタイムを取得します。

ChannelInitializers

クライアントに関連付けられたチャネルをカスタマイズするために使用されるチャネル初期化子オブジェクトのコレクションを取得します。

ClientMessageInspectors

特定のサービス操作のメッセージを表示または変更するために使用されるメッセージ インスペクター オブジェクトのコレクションを取得します。

ClientOperations

特定のサービス操作のメッセージと動作を調査または変更する拡張オブジェクトを追加するために使用するクライアント操作オブジェクトのコレクションを取得します。

ContractClientType

クライアントに関連付けられているコントラクトの型を取得または設定します。

ContractName

クライアントに関連付けられているコントラクトの名前を取得します。

ContractNamespace

クライアントに関連付けられているコントラクトの名前空間を取得します。

DispatchRuntime

クライアント アプリケーションによって処理されるすべてのメッセージの Windows Communication Foundation (WCF) クライアント オブジェクトの機能を拡張するクラスの挿入ポイントを表します。

InteractiveChannelInitializers

対話型チャネル初期化子のコレクションを取得します。

ManualAddressing

クライアントがアドレス指定ヘッダーを要求/応答メッセージに追加するかどうかを示す値を取得または設定します。

MaxFaultSize

最大エラー サイズを取得または設定します。

MessageInspectors

クライアントのメッセージ インスペクターの実装のコレクションを取得します。

MessageVersionNoneFaultsEnabled

MessageVersionNoneFaultsEnabled プロパティが設定されているかどうかを示す値を取得または設定します。

Operations

クライアントに対するクライアント操作のコレクションを取得します。

OperationSelector

IClientOperationSelector を選択するために使用できる ClientOperation の実装を取得または設定します。

UnhandledClientOperation

ClientOperation コレクション内に対応する Operations のないメソッドのクライアント操作を取得します。

ValidateMustUnderstand

システムまたはアプリケーションで SOAP MustUnderstand ヘッダー処理を強制的に行うかどうかを指定する値を取得または設定します。

Via

クライアントを通してメッセージを送信するために使用するトランスポート アドレスを取得または設定します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象