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.

Namespace:   System.ServiceModel.Description
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public static ServiceEndpointCollection Resolve(
	Type contract,
	Uri address,
	MetadataExchangeClientMode mode


Type: System.Type

The contract for which to download and resolve metadata.

Type: System.Uri

The metadata address.

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

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.


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);
ISampleService serviceChannel;
  "\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.");
        "Client used the " + point.Address.ToString() + " address."

.NET Framework
Available since 3.0
Return to top