MetadataResolver::Resolve Method (Type^, Uri^, MetadataExchangeClientMode)
Resolves a metadata address into the ServiceEndpoint objects for the specified contract using the specified address and transfer mode.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
public: static ServiceEndpointCollection^ Resolve( Type^ contract, Uri^ address, MetadataExchangeClientMode mode )
Parameters
- contract
-
Type:
System::Type^
The contract for which to download and resolve metadata.
- address
-
Type:
System::Uri^
The metadata address.
- mode
-
Type:
System.ServiceModel.Description::MetadataExchangeClientMode
The mode of retrieval.
Return Value
Type: System.ServiceModel.Description::ServiceEndpointCollection^A collection of ServiceEndpoint objects for the specified contract.
| Exception | Condition |
|---|---|
| ArgumentNullException | The address or contract is null. |
Use the Resolve method to specify a contract, and address, and the download mechanism to use.
The default settings on the System.ServiceModel.Description::MetadataExchangeClient are used to retrieve the metadata.
To download metadata but not resolve the information into ServiceEndpoint objects, use the System.ServiceModel.Description::MetadataExchangeClient directly.
Note |
|---|
An empty collection is returned if no endpoints were imported or if no endpoints matched the contract. If an empty collection is returned, a warning trace is written. |
The following code example shows the use of the MetadataResolver to download and return metadata as a collection of ServiceEndpoint objects using an HTTP GET request rather than WS-Transfer.
// 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(); } }
Available since 3.0
