MetadataResolver.Resolve メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
メタデータ アドレスをダウンロードし、そのサービスの ServiceEndpoint オブジェクトに解決します。
オーバーロード
| 名前 | 説明 |
|---|---|
| Resolve(IEnumerable<ContractDescription>, EndpointAddress) |
指定したメタデータ アドレスを使用して、指定したコントラクトの ServiceEndpoint オブジェクトにメタデータ アドレスを解決します。 |
| Resolve(Type, EndpointAddress) |
メタデータ アドレスをダウンロードし、指定したアドレスにある指定したコントラクトの ServiceEndpoint オブジェクトのコレクションに解決します。 |
| Resolve(IEnumerable<ContractDescription>, EndpointAddress, MetadataExchangeClient) |
指定したメタデータ アドレスとMetadataExchangeClientを使用して、指定したコントラクトのServiceEndpoint オブジェクトにメタデータ アドレスを解決します。 |
| Resolve(IEnumerable<ContractDescription>, Uri, MetadataExchangeClientMode) |
指定したアドレスと転送モードを使用して、指定したコントラクトのメタデータ アドレスを ServiceEndpoint オブジェクトに解決します。 |
| Resolve(Type, Uri, MetadataExchangeClientMode) |
指定したアドレスと転送モードを使用して、指定したコントラクトの ServiceEndpoint オブジェクトにメタデータ アドレスを解決します。 |
| Resolve(IEnumerable<ContractDescription>, Uri, MetadataExchangeClientMode, MetadataExchangeClient) |
指定したアドレス、転送モード、および転送クライアントを使用して、指定したコントラクトの ServiceEndpoint オブジェクトにメタデータ アドレスを解決します。 |
注釈
メタデータをダウンロードし、情報を ServiceEndpoint オブジェクトに解決しない場合は、 System.ServiceModel.Description.MetadataExchangeClient を直接使用します。
すべての同期および非同期 Resolve メソッドについて、エンドポイントがインポートされなかった場合、またはコントラクトに一致するエンドポイントがない場合は、空のコレクションが返されます。 空のコレクションが返された場合は、警告トレースが書き込まれます。
Resolve(IEnumerable<ContractDescription>, EndpointAddress)
指定したメタデータ アドレスを使用して、指定したコントラクトの ServiceEndpoint オブジェクトにメタデータ アドレスを解決します。
public:
static System::ServiceModel::Description::ServiceEndpointCollection ^ Resolve(System::Collections::Generic::IEnumerable<System::ServiceModel::Description::ContractDescription ^> ^ contracts, System::ServiceModel::EndpointAddress ^ address);
public static System.ServiceModel.Description.ServiceEndpointCollection Resolve(System.Collections.Generic.IEnumerable<System.ServiceModel.Description.ContractDescription> contracts, System.ServiceModel.EndpointAddress address);
static member Resolve : seq<System.ServiceModel.Description.ContractDescription> * System.ServiceModel.EndpointAddress -> System.ServiceModel.Description.ServiceEndpointCollection
Public Shared Function Resolve (contracts As IEnumerable(Of ContractDescription), address As EndpointAddress) As ServiceEndpointCollection
パラメーター
- contracts
- IEnumerable<ContractDescription>
メタデータをダウンロードして解決するコントラクト。
- address
- EndpointAddress
メタデータ アドレス。
返品
指定したコントラクトの ServiceEndpoint オブジェクトのコレクション。
例外
アドレスまたはコントラクトのコレクションが null。
contracts が空であるか、 contracts の少なくとも 1 つのメンバーが null であるか、 contracts が同じ名前と名前空間を持つ複数のコントラクトを含みます。
注釈
System.ServiceModel.Description.MetadataExchangeClientの既定の設定はメタデータの取得に使用され、既定のSystem.ServiceModel.Description.MetadataExchangeClientModeはMetadataExchangeClientMode.MetadataExchange。
メタデータをダウンロードし、情報を ServiceEndpoint オブジェクトに解決しない場合は、 System.ServiceModel.Description.MetadataExchangeClient を直接使用します。
Note
エンドポイントがインポートされなかった場合、またはコントラクトに一致するエンドポイントがない場合は、空のコレクションが返されます。 空のコレクションが返された場合は、警告トレースが書き込まれます。
適用対象
Resolve(Type, EndpointAddress)
メタデータ アドレスをダウンロードし、指定したアドレスにある指定したコントラクトの ServiceEndpoint オブジェクトのコレクションに解決します。
public:
static System::ServiceModel::Description::ServiceEndpointCollection ^ Resolve(Type ^ contract, System::ServiceModel::EndpointAddress ^ address);
public static System.ServiceModel.Description.ServiceEndpointCollection Resolve(Type contract, System.ServiceModel.EndpointAddress address);
static member Resolve : Type * System.ServiceModel.EndpointAddress -> System.ServiceModel.Description.ServiceEndpointCollection
Public Shared Function Resolve (contract As Type, address As EndpointAddress) As ServiceEndpointCollection
パラメーター
- contract
- Type
メタデータをダウンロードして解決するコントラクト。
- address
- EndpointAddress
メタデータ アドレス。
返品
指定したコントラクトの ServiceEndpoint オブジェクトのコレクション。
例外
アドレスまたはコントラクトが null。
例
次のコード例は、 MetadataResolver クラスを使用して、サービス インスタンスへの接続に使用される ServiceEndpoint オブジェクトのコレクションとしてメタデータを返す方法を示しています。
// Get the endpoints for such a service
ServiceEndpointCollection endpoints = MetadataResolver.Resolve(typeof(SampleServiceClient), metaAddress);
Console.WriteLine("Trying all available WS-Transfer metadata endpoints...");
foreach (ServiceEndpoint point in endpoints)
{
if (point != null)
{
// Create a new wcfClient using retrieved endpoints.
wcfClient = new SampleServiceClient(point.Binding, point.Address);
Console.WriteLine(
wcfClient.SampleMethod("Client used the "
+ point.Address.ToString()
+ " address.")
);
wcfClient.Close();
}
}
注釈
Resolve メソッドを使用して、メタデータをダウンロードして解決するときに使用するコントラクトとメタデータ アドレスを指定します。
System.ServiceModel.Description.MetadataExchangeClientの既定の設定はメタデータの取得に使用され、既定のSystem.ServiceModel.Description.MetadataExchangeClientModeはMetadataExchangeClientMode.MetadataExchange。
メタデータをダウンロードし、情報を ServiceEndpoint オブジェクトに解決しない場合は、 System.ServiceModel.Description.MetadataExchangeClient を直接使用します。
Note
エンドポイントがインポートされなかった場合、またはコントラクトに一致するエンドポイントがない場合は、空のコレクションが返されます。 空のコレクションが返された場合は、警告トレースが書き込まれます。
このメソッドでは、コントラクト型を指定する必要があります。 コントラクトを指定するには、クライアント コードでサービス インターフェイスを宣言するか、Svcutil.exeによって生成された WCF クライアントを使用します。 インターフェイスが変更された場合 (新しい操作の追加など)、クライアント コードでインターフェイスを更新するか、新しい WCF クライアントを生成する必要があります。 そうしないと、例外がスローされます。 たとえば、Add()、Sub()、Mult()、Div() を定義する ICalculator というサービス コントラクトを実装するサービスがあるとします。 クライアント アプリケーションを作成し、WCF クライアントを生成します。 次に、Echo() という名前のメソッドを ICalculator に追加します。 その後、新しい WCF クライアントを生成せずに Resolve(Type, EndpointAddress) を呼び出すアプリケーションを記述すると、次の例外が発生します。
Unhandled Exception: System.ServiceModel.Description.WsdlImporter+WsdlImportException: Cannot locate operation Echo in Contract ICalculator。
適用対象
Resolve(IEnumerable<ContractDescription>, EndpointAddress, MetadataExchangeClient)
指定したメタデータ アドレスとMetadataExchangeClientを使用して、指定したコントラクトのServiceEndpoint オブジェクトにメタデータ アドレスを解決します。
public:
static System::ServiceModel::Description::ServiceEndpointCollection ^ Resolve(System::Collections::Generic::IEnumerable<System::ServiceModel::Description::ContractDescription ^> ^ contracts, System::ServiceModel::EndpointAddress ^ address, System::ServiceModel::Description::MetadataExchangeClient ^ client);
public static System.ServiceModel.Description.ServiceEndpointCollection Resolve(System.Collections.Generic.IEnumerable<System.ServiceModel.Description.ContractDescription> contracts, System.ServiceModel.EndpointAddress address, System.ServiceModel.Description.MetadataExchangeClient client);
static member Resolve : seq<System.ServiceModel.Description.ContractDescription> * System.ServiceModel.EndpointAddress * System.ServiceModel.Description.MetadataExchangeClient -> System.ServiceModel.Description.ServiceEndpointCollection
Public Shared Function Resolve (contracts As IEnumerable(Of ContractDescription), address As EndpointAddress, client As MetadataExchangeClient) As ServiceEndpointCollection
パラメーター
- contracts
- IEnumerable<ContractDescription>
メタデータをダウンロードして解決するコントラクト。
- address
- EndpointAddress
メタデータ アドレス。
- client
- MetadataExchangeClient
MetadataExchangeClientメタデータの取得に使用されます。
返品
指定したコントラクトの ServiceEndpoint オブジェクトのコレクション。
例外
アドレス、コントラクトコレクション、またはクライアントが null。
contracts が空であるか、 contracts の少なくとも 1 つのメンバーが null であるか、 contracts が同じ名前と名前空間を持つ複数のコントラクトを含みます。
注釈
既定の System.ServiceModel.Description.MetadataExchangeClientMode は MetadataExchangeClientMode.MetadataExchange です。
メタデータをダウンロードし、情報を ServiceEndpoint オブジェクトに解決しない場合は、 System.ServiceModel.Description.MetadataExchangeClient を直接使用します。
Note
エンドポイントがインポートされなかった場合、またはコントラクトに一致するエンドポイントがない場合は、空のコレクションが返されます。 空のコレクションが返された場合は、警告トレースが書き込まれます。
適用対象
Resolve(IEnumerable<ContractDescription>, Uri, MetadataExchangeClientMode)
指定したアドレスと転送モードを使用して、指定したコントラクトのメタデータ アドレスを ServiceEndpoint オブジェクトに解決します。
public:
static System::ServiceModel::Description::ServiceEndpointCollection ^ Resolve(System::Collections::Generic::IEnumerable<System::ServiceModel::Description::ContractDescription ^> ^ contracts, Uri ^ address, System::ServiceModel::Description::MetadataExchangeClientMode mode);
public static System.ServiceModel.Description.ServiceEndpointCollection Resolve(System.Collections.Generic.IEnumerable<System.ServiceModel.Description.ContractDescription> contracts, Uri address, System.ServiceModel.Description.MetadataExchangeClientMode mode);
static member Resolve : seq<System.ServiceModel.Description.ContractDescription> * Uri * System.ServiceModel.Description.MetadataExchangeClientMode -> System.ServiceModel.Description.ServiceEndpointCollection
Public Shared Function Resolve (contracts As IEnumerable(Of ContractDescription), address As Uri, mode As MetadataExchangeClientMode) As ServiceEndpointCollection
パラメーター
- contracts
- IEnumerable<ContractDescription>
メタデータをダウンロードして解決するコントラクト。
- address
- Uri
メタデータ アドレス。
取得モード。
返品
指定したコントラクトの ServiceEndpoint オブジェクトのコレクション。
例外
アドレスまたはコントラクトのコレクションが null。
contracts が空であるか、 contracts の少なくとも 1 つのメンバーが null であるか、 contracts が同じ名前と名前空間を持つ複数のコントラクトを含みます。
注釈
System.ServiceModel.Description.MetadataExchangeClientの既定の設定は、メタデータの取得に使用されます。
メタデータをダウンロードし、情報を ServiceEndpoint オブジェクトに解決しない場合は、 System.ServiceModel.Description.MetadataExchangeClient を直接使用します。
Note
エンドポイントがインポートされなかった場合、またはコントラクトに一致するエンドポイントがない場合は、空のコレクションが返されます。 空のコレクションが返された場合は、警告トレースが書き込まれます。
適用対象
Resolve(Type, Uri, MetadataExchangeClientMode)
指定したアドレスと転送モードを使用して、指定したコントラクトの ServiceEndpoint オブジェクトにメタデータ アドレスを解決します。
public:
static System::ServiceModel::Description::ServiceEndpointCollection ^ Resolve(Type ^ contract, Uri ^ address, System::ServiceModel::Description::MetadataExchangeClientMode mode);
public static System.ServiceModel.Description.ServiceEndpointCollection Resolve(Type contract, Uri address, System.ServiceModel.Description.MetadataExchangeClientMode mode);
static member Resolve : Type * Uri * System.ServiceModel.Description.MetadataExchangeClientMode -> System.ServiceModel.Description.ServiceEndpointCollection
Public Shared Function Resolve (contract As Type, address As Uri, mode As MetadataExchangeClientMode) As ServiceEndpointCollection
パラメーター
- contract
- Type
メタデータをダウンロードして解決するコントラクト。
- address
- Uri
メタデータ アドレス。
取得モード。
返品
指定したコントラクトの ServiceEndpoint オブジェクトのコレクション。
例外
アドレスまたはコントラクトが null。
例
次のコード例は、WS-Transfer ではなく HTTP GET 要求を使用して、 MetadataResolver を使用してメタデータをダウンロードし、 ServiceEndpoint オブジェクトのコレクションとして返す方法を示しています。
// Get the endpoints for such a service using Http/Get request
endpoints = MetadataResolver.Resolve(typeof(SampleServiceClient), httpGetMetaAddress.Uri, MetadataExchangeClientMode.HttpGet);
Client.WriteParameters(endpoints);
ISampleService serviceChannel;
Console.WriteLine(
"\r\nTrying all endpoints from HTTP/Get and with direct service channels...");
foreach (ServiceEndpoint point in endpoints)
{
if (point != null)
{
ChannelFactory<ISampleService> factory = new ChannelFactory<ISampleService>(point.Binding);
factory.Endpoint.Address = point.Address;
serviceChannel = factory.CreateChannel();
Console.WriteLine("Client used the " + point.Address.ToString() + " address.");
Console.WriteLine(
serviceChannel.SampleMethod(
"Client used the " + point.Address.ToString() + " address."
)
);
factory.Close();
}
}
注釈
Resolve メソッドを使用して、コントラクトとアドレス、および使用するダウンロード メカニズムを指定します。
System.ServiceModel.Description.MetadataExchangeClientの既定の設定は、メタデータの取得に使用されます。
メタデータをダウンロードし、情報を ServiceEndpoint オブジェクトに解決しない場合は、 System.ServiceModel.Description.MetadataExchangeClient を直接使用します。
Note
エンドポイントがインポートされなかった場合、またはコントラクトに一致するエンドポイントがない場合は、空のコレクションが返されます。 空のコレクションが返された場合は、警告トレースが書き込まれます。
適用対象
Resolve(IEnumerable<ContractDescription>, Uri, MetadataExchangeClientMode, MetadataExchangeClient)
指定したアドレス、転送モード、および転送クライアントを使用して、指定したコントラクトの ServiceEndpoint オブジェクトにメタデータ アドレスを解決します。
public:
static System::ServiceModel::Description::ServiceEndpointCollection ^ Resolve(System::Collections::Generic::IEnumerable<System::ServiceModel::Description::ContractDescription ^> ^ contracts, Uri ^ address, System::ServiceModel::Description::MetadataExchangeClientMode mode, System::ServiceModel::Description::MetadataExchangeClient ^ client);
public static System.ServiceModel.Description.ServiceEndpointCollection Resolve(System.Collections.Generic.IEnumerable<System.ServiceModel.Description.ContractDescription> contracts, Uri address, System.ServiceModel.Description.MetadataExchangeClientMode mode, System.ServiceModel.Description.MetadataExchangeClient client);
static member Resolve : seq<System.ServiceModel.Description.ContractDescription> * Uri * System.ServiceModel.Description.MetadataExchangeClientMode * System.ServiceModel.Description.MetadataExchangeClient -> System.ServiceModel.Description.ServiceEndpointCollection
Public Shared Function Resolve (contracts As IEnumerable(Of ContractDescription), address As Uri, mode As MetadataExchangeClientMode, client As MetadataExchangeClient) As ServiceEndpointCollection
パラメーター
- contracts
- IEnumerable<ContractDescription>
メタデータをダウンロードして解決するコントラクト。
- address
- Uri
メタデータ アドレス。
取得モード。
- client
- MetadataExchangeClient
MetadataExchangeClientメタデータの取得に使用されます。
返品
指定したコントラクトの ServiceEndpoint オブジェクトのコレクション。
例外
アドレス、コントラクトコレクション、またはクライアントが null。
contracts が空であるか、 contracts の少なくとも 1 つのメンバーが null であるか、 contracts が同じ名前と名前空間を持つ複数のコントラクトを含みます。
注釈
メタデータをダウンロードし、情報を ServiceEndpoint オブジェクトに解決しない場合は、 System.ServiceModel.Description.MetadataExchangeClient を直接使用します。
Note
エンドポイントがインポートされなかった場合、またはコントラクトに一致するエンドポイントがない場合は、空のコレクションが返されます。 空のコレクションが返された場合は、警告トレースが書き込まれます。