ClientBase<TChannel> クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
サービスを呼び出すことができる Windows Communication Foundation (WCF) クライアント オブジェクトを作成するために使用する基本実装を用意します。
generic <typename TChannel>
where TChannel : classpublic ref class ClientBase abstract : System::ServiceModel::ICommunicationObject
generic <typename TChannel>
where TChannel : classpublic ref class ClientBase abstract : IAsyncDisposable, IDisposable, System::ServiceModel::ICommunicationObject
generic <typename TChannel>
where TChannel : classpublic ref class ClientBase abstract : IDisposable, System::ServiceModel::ICommunicationObject
public abstract class ClientBase<TChannel> : System.ServiceModel.ICommunicationObject where TChannel : class
public abstract class ClientBase<TChannel> : IAsyncDisposable, IDisposable, System.ServiceModel.ICommunicationObject where TChannel : class
public abstract class ClientBase<TChannel> : IDisposable, System.ServiceModel.ICommunicationObject where TChannel : class
type ClientBase<'Channel (requires 'Channel : null)> = class
interface ICommunicationObject
type ClientBase<'Channel (requires 'Channel : null)> = class
interface ICommunicationObject
interface IDisposable
interface IAsyncDisposable
type ClientBase<'Channel (requires 'Channel : null)> = class
interface ICommunicationObject
interface IDisposable
Public MustInherit Class ClientBase(Of TChannel)
Implements ICommunicationObject
Public MustInherit Class ClientBase(Of TChannel)
Implements IAsyncDisposable, ICommunicationObject, IDisposable
Public MustInherit Class ClientBase(Of TChannel)
Implements ICommunicationObject, IDisposable
型パラメーター
- TChannel
サービスに接続するために使用されるチャネル。
- 継承
-
ClientBase<TChannel>
- 派生
- 実装
例
次のコード例は、 ServiceModel メタデータ ユーティリティ ツール (Svcutil.exe) が クラスを ClientBase<TChannel> 拡張して WCF クライアント クラスを作成する方法を示しています。
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 の動作をエミュレートする必要があります。
コンストラクター
プロパティ
CacheSetting |
キャッシュ設定を取得または設定します。 |
Channel |
さまざまな構成のサービス エンドポイントにメッセージを送信するために使用する内部チャネルを取得します。 |
ChannelFactory |
基になる ChannelFactory<TChannel> オブジェクトを取得します。 |
ClientCredentials |
操作を呼び出すために使用されるクライアント資格情報を取得します。 |
Endpoint |
WCF クライアントが接続できるサービスのターゲット エンドポイントを取得します。 |
InnerChannel |
基になる IClientChannel 実装を取得します。 |
State |
ClientBase<TChannel> オブジェクトの現在の状態を取得します。 |
メソッド
Abort() |
ClientBase<TChannel> オブジェクトを、現在の状態から Closed 状態に直ちに遷移させます。 |
Close() |
ClientBase<TChannel> オブジェクトを、現在の状態から Closed 状態に遷移させます。 |
CloseAsync() |
サービスを呼び出すことができる Windows Communication Foundation (WCF) クライアント オブジェクトを作成するために使用する基本実装を用意します。 |
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 状態に遷移させます。 |
OpenAsync() |
サービスを呼び出すことができる Windows Communication Foundation (WCF) クライアント オブジェクトを作成するために使用する基本実装を用意します。 |
ToString() |
現在のオブジェクトを表す文字列を返します。 (継承元 Object) |
明示的なインターフェイスの実装
拡張メソッド
CloseHelperAsync(ICommunicationObject, TimeSpan) |
サービスを呼び出すことができる Windows Communication Foundation (WCF) クライアント オブジェクトを作成するために使用する基本実装を用意します。 |
OpenHelperAsync(ICommunicationObject, TimeSpan) |
サービスを呼び出すことができる Windows Communication Foundation (WCF) クライアント オブジェクトを作成するために使用する基本実装を用意します。 |
ConfigureAwait(IAsyncDisposable, Boolean) |
非同期の破棄可能から返されるタスク上での待機がどのように実行されるかを構成します。 |
適用対象
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示