ClientBase<TChannel> クラス

定義

サービスを呼び出すことができる Windows Communication Foundation (WCF) クライアント オブジェクトを作成するために使用する基本実装を用意します。

generic <typename TChannel>
 where TChannel : classpublic ref class ClientBase abstract : IDisposable, System::ServiceModel::ICommunicationObject
generic <typename TChannel>
 where TChannel : classpublic ref class ClientBase abstract : System::ServiceModel::ICommunicationObject
public abstract class ClientBase<TChannel> : IDisposable, System.ServiceModel.ICommunicationObject where TChannel : class
public abstract class ClientBase<TChannel> : System.ServiceModel.ICommunicationObject where TChannel : class
type ClientBase<'Channel (requires 'Channel : null)> = class
    interface IDisposable
    interface ICommunicationObject
type ClientBase<'Channel (requires 'Channel : null)> = class
    interface ICommunicationObject
type ClientBase<'Channel (requires 'Channel : null)> = class
    interface ICommunicationObject
    interface IDisposable
Public MustInherit Class ClientBase(Of TChannel)
Implements ICommunicationObject, IDisposable
Public MustInherit Class ClientBase(Of TChannel)
Implements ICommunicationObject

型パラメーター

TChannel

サービスに接続するために使用されるチャネル。

継承
ClientBase<TChannel>
派生
実装

次のコード例は、 ServiceModel メタデータ ユーティリティ ツール (Svcutil.exe) が WCF クライアント クラスを作成するためにクラスを ClientBase<TChannel> 拡張する方法を示しています。

public partial class SampleServiceClient : System.ServiceModel.ClientBase<ISampleService>, ISampleService
{

    public SampleServiceClient()
    {
    }

    public SampleServiceClient(string endpointConfigurationName) :
            base(endpointConfigurationName)
    {
    }

    public SampleServiceClient(string endpointConfigurationName, string remoteAddress) :
            base(endpointConfigurationName, remoteAddress)
    {
    }

    public SampleServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
            base(endpointConfigurationName, remoteAddress)
    {
    }

    public SampleServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
            base(binding, remoteAddress)
    {
    }

    public string SampleMethod(string msg)
    {
        return base.Channel.SampleMethod(msg);
    }
}
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")> _
Partial Public Class SampleServiceClient
    Inherits System.ServiceModel.ClientBase(Of ISampleService)
    Implements ISampleService

    Public Sub New()
    End Sub

    Public Sub New(ByVal endpointConfigurationName As String)
        MyBase.New(endpointConfigurationName)
    End Sub

    Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
        MyBase.New(endpointConfigurationName, remoteAddress)
    End Sub

    Public Sub New(ByVal endpointConfigurationName As String, _
                   ByVal remoteAddress As System.ServiceModel.EndpointAddress)
        MyBase.New(endpointConfigurationName, remoteAddress)
    End Sub

    Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, _
                   ByVal remoteAddress As System.ServiceModel.EndpointAddress)
        MyBase.New(binding, remoteAddress)
    End Sub

    Public Function SampleMethod(ByVal msg As String) As String Implements ISampleService.SampleMethod
        Return MyBase.Channel.SampleMethod(msg)
    End Function
End Class

注釈

クラスを ClientBase<TChannel> 拡張して、サービスへの接続に使用できるカスタム WCF クライアント オブジェクトを作成します。 通常、WCF クライアントの基本クラスは、ユーザーの代わりに ServiceModel メタデータ ユーティリティ ツール (Svcutil.exe) などのツール によって拡張されます。 例については、「例」のセクションを参照してください。

ClientBase<TChannel> は、開発者がインターフェイスと System.ServiceModel.ChannelFactory<TChannel> クラスではなくオブジェクトの使用を希望する場合に、容易に使用できるクラスです。 どのような場合でも、このクラスは、System.ServiceModel.ChannelFactory<TChannel> クラスと System.ServiceModel.IClientChannel インターフェイスのメソッドと機能をラップまたは公開します。

System.ServiceModel.ServiceHost クラスを使用しているときは、任意の呼び出しを行うとき、または Open を呼び出す前に、このクラスを作成して、エンドポイント、チャネル ファクトリ、またはセキュリティ情報を変更できます。 詳細については、「 WCF クライアントの概要 」および「WCF クライアント を使用したサービスへのアクセス」を参照してください

このクラスから派生するマネージド C++ ユーザーに対する特別な注意 :

  • クリーンアップ コードは、デストラクターではなく (On)(Begin)Close (または OnAbort のどちらか一方または両方) に置いてください。

  • デストラクターは使用しないでください。使用すると、コンパイラが IDisposable を自動生成します。

  • 非参照メンバーを使用しないでください。使用すると、コンパイラが IDisposable を自動生成します。

  • ファイナライザーを使用しないでください。使用する場合は、ビルド警告を抑制し、SuppressFinalize(Object) を呼び出し、ファイナライザー自体を (On)(Begin)Close (または OnAbort のどちらか一方または両方) から呼び出して、自動生成される IDisposable の動作をエミュレートする必要があります。

コンストラクター

ClientBase<TChannel>()

アプリケーション構成ファイルの既定のターゲット エンドポイントを使用して、ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(Binding, EndpointAddress)

指定したバインドとターゲット アドレスを使用して、ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(InstanceContext)

ClientBase<TChannel> クラスを双方向通信でのコールバック オブジェクトとして使用する callbackInstance クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(InstanceContext, Binding, EndpointAddress)

ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(InstanceContext, ServiceEndpoint)

指定した ClientBase<TChannel> オブジェクトと InstanceContext オブジェクトを使用して、ServiceEndpoint クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(InstanceContext, String)

指定したコールバック サービスとエンドポイント構成情報を使用して、ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(InstanceContext, String, EndpointAddress)

ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(InstanceContext, String, String)

ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(ServiceEndpoint)

指定した ServiceEndpoint を使用して、ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(String)

ClientBase<TChannel> によるアプリケーション構成ファイルに指定された構成情報を使用して、endpointConfigurationName クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(String, EndpointAddress)

指定したターゲット アドレスとエンドポイント情報を使用して、ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

ClientBase<TChannel>(String, String)

ClientBase<TChannel> クラスの新しいインスタンスを初期化します。

プロパティ

CacheSetting

キャッシュ設定を取得または設定します。

Channel

さまざまな構成のサービス エンドポイントにメッセージを送信するために使用する内部チャネルを取得します。

ChannelFactory

基になる ChannelFactory<TChannel> オブジェクトを取得します。

ClientCredentials

操作を呼び出すために使用されるクライアント資格情報を取得します。

Endpoint

WCF クライアントが接続できるサービスのターゲット エンドポイントを取得します。

InnerChannel

基になる IClientChannel 実装を取得します。

State

ClientBase<TChannel> オブジェクトの現在の状態を取得します。

メソッド

Abort()

ClientBase<TChannel> オブジェクトを、現在の状態から Closed 状態に直ちに遷移させます。

Close()

ClientBase<TChannel> オブジェクトを、現在の状態から Closed 状態に遷移させます。

CreateChannel()

サービスへの新しいチャネルを返します。

DisplayInitializationUI()

使用前にチャネルを初期化するときにユーザー インターフェイスが必要な場合は、ユーザー インターフェイスを表示するように内部チャネルに指示します。

Equals(Object)

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

(継承元 Object)
GetDefaultValueForInitialization<T>()

C# の既定のキーワードの動作をレプリケートします。

GetHashCode()

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

(継承元 Object)
GetType()

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

(継承元 Object)
InvokeAsync(ClientBase<TChannel>.BeginOperationDelegate, Object[], ClientBase<TChannel>.EndOperationDelegate, SendOrPostCallback, Object)

イベント ベースの非同期パターンをサポートします。 このパターンの詳細については、「イベント ベースの非同期パターンの概要」を参照してください。

MemberwiseClone()

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

(継承元 Object)
Open()

ClientBase<TChannel> オブジェクトを、Created 状態から Opened 状態に遷移させます。

ToString()

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

(継承元 Object)

明示的なインターフェイスの実装

ICommunicationObject.BeginClose(AsyncCallback, Object)

ClientBase<TChannel> を閉じるための非同期操作を開始します。

ICommunicationObject.BeginClose(TimeSpan, AsyncCallback, Object)

指定したタイムアウトで ClientBase<TChannel> を閉じるための非同期操作を開始します。

ICommunicationObject.BeginOpen(AsyncCallback, Object)

ClientBase<TChannel> オブジェクトを開くための非同期操作を開始します。

ICommunicationObject.BeginOpen(TimeSpan, AsyncCallback, Object)

指定した時間内で ClientBase<TChannel> オブジェクトを開くための非同期操作を開始します。

ICommunicationObject.Close()

通信オブジェクトを、現在の状態から Closed 状態に遷移させます。

ICommunicationObject.Close(TimeSpan)

ClientBase<TChannel> オブジェクトを、現在の状態から Closed 状態に遷移させます。

ICommunicationObject.Closed

ClientBase<TChannel> オブジェクトが現在の状態から Closed 状態に遷移するときに呼び出されるイベント ハンドラーです。

ICommunicationObject.Closing

ClientBase<TChannel> オブジェクトが現在の状態から Closed 状態に遷移するときに呼び出されるイベント ハンドラーです。

ICommunicationObject.EndClose(IAsyncResult)

ClientBase<TChannel> オブジェクトを閉じるための非同期操作を完了します。

ICommunicationObject.EndOpen(IAsyncResult)

ClientBase<TChannel> オブジェクトを開くための非同期操作を完了します。

ICommunicationObject.Faulted

ClientBase<TChannel> オブジェクトに対する操作の実行中にエラーが発生したときに呼び出されるイベント ハンドラーです。

ICommunicationObject.Open()

通信オブジェクトを、Created 状態から Opened 状態に遷移させます。

ICommunicationObject.Open(TimeSpan)

指定した時間内に、ClientBase<TChannel> オブジェクトを、Created 状態から Opened 状態に遷移させます。

ICommunicationObject.Opened

ClientBase<TChannel> オブジェクトが Created 状態から Opened 状態に遷移するときに呼び出されるイベント ハンドラーです。

ICommunicationObject.Opening

ClientBase<TChannel> オブジェクトが Created 状態から Opened 状態に遷移するときに呼び出されるイベント ハンドラーです。

IDisposable.Dispose()

Dispose() メソッドの明示的な実装です。

適用対象