CustomBinding クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
バインド要素の一覧からバインドを定義します。
public ref class CustomBinding : System::ServiceModel::Channels::Binding
public class CustomBinding : System.ServiceModel.Channels.Binding
[System.Windows.Markup.ContentProperty("Elements")]
public class CustomBinding : System.ServiceModel.Channels.Binding
type CustomBinding = class
inherit Binding
[<System.Windows.Markup.ContentProperty("Elements")>]
type CustomBinding = class
inherit Binding
Public Class CustomBinding
Inherits Binding
- 継承
- 属性
例
次の例では、CustomBinding および ReliableSessionBindingElement を使用して HttpTransportBindingElement オブジェクトを作成する方法を示します。
Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service");
// Create a ServiceHost for the CalculatorService type and provide the base address.
using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress))
{
// Create a custom binding that contains two binding elements.
ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement();
reliableSession.Ordered = true;
HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();
httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
CustomBinding binding = new CustomBinding(reliableSession, httpTransport);
// Add an endpoint using that binding.
serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, "");
// Add a MEX endpoint.
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.HttpGetUrl = new Uri("http://localhost:8001/servicemodelsamples");
serviceHost.Description.Behaviors.Add(smb);
// Open the ServiceHostBase to create listeners and start listening for messages.
serviceHost.Open();
// The service can now be accessed.
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
// Close the ServiceHostBase to shutdown the service.
serviceHost.Close();
}
Dim baseAddress As New Uri("http://localhost:8000/servicemodelsamples/service")
' Create a ServiceHost for the CalculatorService type and provide the base address.
Using serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)
' Create a custom binding that contains two binding elements.
Dim reliableSession As New ReliableSessionBindingElement()
reliableSession.Ordered = True
Dim httpTransport As New HttpTransportBindingElement()
httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous
httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard
Dim binding As New CustomBinding(reliableSession, httpTransport)
' Add an endpoint using that binding.
serviceHost.AddServiceEndpoint(GetType(ICalculator), binding, "")
' Add a MEX endpoint.
Dim smb As New ServiceMetadataBehavior()
smb.HttpGetEnabled = True
smb.HttpGetUrl = New Uri("http://localhost:8001/servicemodelsamples")
serviceHost.Description.Behaviors.Add(smb)
' Open the ServiceHostBase to create listeners and start listening for messages.
serviceHost.Open()
' The service can now be accessed.
Console.WriteLine("The service is ready.")
Console.WriteLine("Press <ENTER> to terminate service.")
Console.WriteLine()
Console.ReadLine()
' Close the ServiceHostBase to shutdown the service.
serviceHost.Close()
End Using
注釈
システムが提供するバインディングの中にサービスの要件を満たすものがない場合は、カスタム バインドを使用します。 たとえば、カスタム バインドを使用すると、サービス エンドポイントで新しいトランスポートや新しいエンコーダーを使用できます。
カスタム バインドは、特定の順序で "積み重ねられている" バインド要素のコレクションから CustomBinding の 1 つを使用して作成します。
最上位にあるのは、トランザクションのフローを可能にするオプションの TransactionFlowBindingElement です。
その次にあるのは、WS-ReliableMessaging 仕様で定義されているセッションおよび順序指定のメカニズムを提供するオプションの ReliableSessionBindingElement です。 このセッションの概念は、SOAP およびトランスポート中継局を通過できます。
その次にあるのは、承認、認証、保護、機密性などのセキュリティ機能を提供するオプションのセキュリティ バインド要素です。 次のセキュリティ バインディング要素が Windows Communication Foundation (WCF) から提供されます。
その次にあるのは、バインド要素によって指定されるオプションのメッセージ パターンです。
その次にあるのは、オプションのトランスポート アップグレード/ヘルパー バインド要素です。
その次にあるのは、必須のメッセージ エンコード バインド要素です。 独自のトランスポートを使用することも、以下のメッセージ エンコード バインドのいずれかを使用することもできます。
最下位には、必須のトランスポート要素があります。 独自のトランスポートを使用するか、Windows Communication Foundation (WCF) から提供されるトランスポート バインディング要素の 1 つを使用できます。
各層のオプションの概要を次の表に示します。
レイヤー | Options | 必須 |
---|---|---|
トランザクション フロー | TransactionFlowBindingElement | いいえ |
[信頼性] | ReliableSessionBindingElement | いいえ |
セキュリティ | 同期、非同期、トランスポート レベル | いいえ |
形状の変更 | CompositeDuplexBindingElement | いいえ |
トランスポートのアップグレード | SSL ストリーム、Windows ストリーム、ピア リゾルバー | いいえ |
エンコード | テキスト、バイナリ、MTOM、カスタム | はい |
トランスポート | TCP、名前付きパイプ、HTTP、HTTPS、MSMQ のフレーバー、カスタム | はい |
さらに、独自のバインド要素を定義し、それを定義済みの層のいずれかの間に挿入できます。
カスタム バインディングを使用し、システム提供のバインディングを変更する方法については、「方法: システム指定のバインディングをカスタマイズする」を参照してください。
注意
.NET Framework 3.5 以前でビルドされた WCF クライアント アプリケーションから .NET Framework 4.0 以降でビルドされた WCF サービスを呼び出す場合、svcutil.exeまたは Visual Studio からサービス参照を追加することによって生成される構成ファイルには、バインド構成に validity 属性が含まれます。 この属性は、.NET Framework 3.5 ランタイムでは認識されず、アプリケーションは "認識されない属性の有効性" というメッセージで をConfigurationErrorsExceptionスローします。 この問題を回避するには、バインド構成から validity 属性を削除します。
コンストラクター
CustomBinding() |
CustomBinding クラスの新しいインスタンスを初期化します。 |
CustomBinding(Binding) |
指定したバインディングの値を使用して、CustomBinding クラスの新しいインスタンスを初期化します。 |
CustomBinding(BindingElement[]) |
バインド要素の配列を使用して CustomBinding クラスの新しいインスタンスを初期化します。 |
CustomBinding(IEnumerable<BindingElement>) |
完全なチャネル スタックのバインディング要素を使用して、CustomBinding クラスの新しいインスタンスを初期化します。 |
CustomBinding(String) |
CustomBinding クラスの新しいインスタンスを初期化します。 |
CustomBinding(String, String, BindingElement[]) |
指定した名前と名前空間を使用して、バインド要素の配列から CustomBinding クラスの新しいインスタンスを初期化します。 |
プロパティ
CloseTimeout |
接続の終了を待機する時間間隔を取得および設定します。これを超えるとトランスポートで例外が発生します。 (継承元 Binding) |
Elements |
カスタム バインドからバインド要素を取得します。 |
MessageVersion |
バインディングで構成されるクライアントとサービスが使用するメッセージ バージョンを取得します。 (継承元 Binding) |
Name |
バインディングの名前を取得または設定します。 (継承元 Binding) |
Namespace |
バインドの XML 名前空間を取得または設定します。 (継承元 Binding) |
OpenTimeout |
接続の確立を待機する時間間隔を取得および設定します。これを超えるとトランスポートで例外が発生します。 (継承元 Binding) |
ReceiveTimeout |
アプリケーション メッセージが受信されない間に、接続が非アクティブになってから切断されるまでの時間を取得または設定します。 (継承元 Binding) |
Scheme |
カスタム バインドが使用するトランスポートの URI スキームを取得します。 |
SendTimeout |
書き込み操作の完了を待機する時間間隔を取得および設定します。これを超えるとトランスポートで例外が発生します。 (継承元 Binding) |
メソッド
BuildChannelFactory<TChannel>(BindingParameterCollection) |
指定した種類のチャネルを作成し、バインド パラメーターのコレクションで指定されている機能を満たすチャネル ファクトリ スタックを、クライアント上に構築します。 (継承元 Binding) |
BuildChannelFactory<TChannel>(Object[]) |
指定した種類のチャネルを作成し、オブジェクト配列で指定されている機能を満たすチャネル ファクトリ スタックを、クライアント上に構築します。 (継承元 Binding) |
BuildChannelListener<TChannel>(BindingParameterCollection) |
指定した種類のチャネルを受け入れ、バインド パラメーターのコレクションで指定されている機能を満たすチャネル リスナーを、サービス上に構築します。 (継承元 Binding) |
BuildChannelListener<TChannel>(Object[]) |
指定した種類のチャネルを受け入れ、指定した機能を満たすチャネル リスナーを、サービス上に構築します。 (継承元 Binding) |
BuildChannelListener<TChannel>(Uri, BindingParameterCollection) |
指定した種類のチャネルを受け入れ、指定した機能を満たすチャネル リスナーを、サービス上に構築します。 (継承元 Binding) |
BuildChannelListener<TChannel>(Uri, Object[]) |
指定した種類のチャネルを受け入れ、指定した機能を満たすチャネル リスナーを、サービス上に構築します。 (継承元 Binding) |
BuildChannelListener<TChannel>(Uri, String, BindingParameterCollection) |
指定した種類のチャネルを受け入れ、指定した機能を満たすチャネル リスナーを、サービス上に構築します。 (継承元 Binding) |
BuildChannelListener<TChannel>(Uri, String, ListenUriMode, BindingParameterCollection) |
指定した種類のチャネルを受け入れ、指定した機能を満たすチャネル リスナーを、サービス上に構築します。 (継承元 Binding) |
BuildChannelListener<TChannel>(Uri, String, ListenUriMode, Object[]) |
指定した種類のチャネルを受け入れ、指定した機能を満たすチャネル リスナーを、サービス上に構築します。 (継承元 Binding) |
BuildChannelListener<TChannel>(Uri, String, Object[]) |
指定した種類のチャネルを受け入れ、指定した機能を満たすチャネル リスナーを、サービス上に構築します。 (継承元 Binding) |
CanBuildChannelFactory<TChannel>(BindingParameterCollection) |
指定したバインド パラメーターのコレクションを満たすチャネル ファクトリ スタックを、現在のバインドがクライアント上に構築できるかどうかを示す値を返します。 (継承元 Binding) |
CanBuildChannelFactory<TChannel>(Object[]) |
オブジェクト配列で指定した要件を満たすチャネル ファクトリ スタックを、現在のバインドがクライアント上に構築できるかどうかを示す値を返します。 (継承元 Binding) |
CanBuildChannelListener<TChannel>(BindingParameterCollection) |
指定したバインド パラメーターのコレクションを満たすチャネル リスナー スタックを、現在のバインドがサービス上に構築できるかどうかを示す値を返します。 (継承元 Binding) |
CanBuildChannelListener<TChannel>(Object[]) |
オブジェクトの配列で指定した条件を満たすチャネル リスナー スタックを、現在のバインドがサービス上に構築できるかどうかを示す値を返します。 (継承元 Binding) |
CreateBindingElements() |
カスタム バインドのバインド要素のジェネリック コレクションを返します。 |
Equals(Object) |
指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。 (継承元 Object) |
GetHashCode() |
既定のハッシュ関数として機能します。 (継承元 Object) |
GetProperty<T>(BindingParameterCollection) |
バインド スタックの適切な層から、要求のあった型指定されたオブジェクト (ある場合) を返します。 (継承元 Binding) |
GetType() |
現在のインスタンスの Type を取得します。 (継承元 Object) |
MemberwiseClone() |
現在の Object の簡易コピーを作成します。 (継承元 Object) |
ShouldSerializeName() |
バインドの名前をシリアル化する必要があるかどうかを示す値を返します。 (継承元 Binding) |
ShouldSerializeNamespace() |
バインドの名前空間をシリアル化する必要があるかどうかを示す値を返します。 (継承元 Binding) |
ToString() |
現在のオブジェクトを表す文字列を返します。 (継承元 Object) |
適用対象
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示