MetadataResolver Class

 

Retrieves and imports metadata as ServiceEndpoint objects.

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

System.Object
  System.ServiceModel.Description.MetadataResolver

public static class MetadataResolver

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticBeginResolve(IEnumerable<ContractDescription>, EndpointAddress, AsyncCallback, Object)

Begins an asynchronous call that resolves a metadata address into the ServiceEndpoint objects for the specified contracts, using the specified address and asynchronous state and delegate.

System_CAPS_pubmethodSystem_CAPS_staticBeginResolve(IEnumerable<ContractDescription>, EndpointAddress, MetadataExchangeClient, AsyncCallback, Object)

Begins an asynchronous call that resolves a metadata address into the ServiceEndpoint objects for the specified contracts, using the specified address, System.ServiceModel.Description.MetadataExchangeClient, asynchronous state and delegate.

System_CAPS_pubmethodSystem_CAPS_staticBeginResolve(IEnumerable<ContractDescription>, Uri, MetadataExchangeClientMode, AsyncCallback, Object)

Begins an asynchronous call that resolves a metadata address into the ServiceEndpoint objects for the specified contracts, using the specified address, System.ServiceModel.Description.MetadataExchangeClientMode value, asynchronous state and delegate.

System_CAPS_pubmethodSystem_CAPS_staticBeginResolve(IEnumerable<ContractDescription>, Uri, MetadataExchangeClientMode, MetadataExchangeClient, AsyncCallback, Object)

Begins an asynchronous call that resolves a metadata address into the ServiceEndpoint objects for the specified contracts, using the specified address, System.ServiceModel.Description.MetadataExchangeClient, System.ServiceModel.Description.MetadataExchangeClientMode, asynchronous state, and delegate.

System_CAPS_pubmethodSystem_CAPS_staticBeginResolve(Type, EndpointAddress, AsyncCallback, Object)

Begins an asynchronous call that resolves a metadata address into the ServiceEndpoint objects for the specified contract using the specified address and asynchronous state and delegate.

System_CAPS_pubmethodSystem_CAPS_staticBeginResolve(Type, Uri, MetadataExchangeClientMode, AsyncCallback, Object)

Begins an asynchronous call that resolves a metadata address into the ServiceEndpoint objects for the specified contract, using the specified address, System.ServiceModel.Description.MetadataExchangeClientMode, asynchronous state and delegate.

System_CAPS_pubmethodSystem_CAPS_staticEndResolve(IAsyncResult)

Completes an asynchronous call to resolve metadata into a collection of endpoints.

System_CAPS_pubmethodSystem_CAPS_staticResolve(IEnumerable<ContractDescription>, EndpointAddress)

Resolves a metadata address into the ServiceEndpoint objects for the specified contracts using the specified metadata address.

System_CAPS_pubmethodSystem_CAPS_staticResolve(IEnumerable<ContractDescription>, EndpointAddress, MetadataExchangeClient)

Resolves a metadata address into the ServiceEndpoint objects for the specified contracts using the specified metadata address and System.ServiceModel.Description.MetadataExchangeClient.

System_CAPS_pubmethodSystem_CAPS_staticResolve(IEnumerable<ContractDescription>, Uri, MetadataExchangeClientMode)

Resolves a metadata address into the ServiceEndpoint objects for the specified contracts using the specified address and transfer mode.

System_CAPS_pubmethodSystem_CAPS_staticResolve(IEnumerable<ContractDescription>, Uri, MetadataExchangeClientMode, MetadataExchangeClient)

Resolves a metadata address into the ServiceEndpoint objects for the specified contracts using the specified address, transfer mode, and transfer client.

System_CAPS_pubmethodSystem_CAPS_staticResolve(Type, EndpointAddress)

Downloads and resolves a metadata address into a collection of ServiceEndpoint objects for a specified contract at a specified address.

System_CAPS_pubmethodSystem_CAPS_staticResolve(Type, Uri, MetadataExchangeClientMode)

Resolves a metadata address into the ServiceEndpoint objects for the specified contract using the specified address and transfer mode.

Use the MetadataResolver class to quickly import endpoints for a service from metadata. This class downloads and converts metadata into ServiceEndpoint objects. To download metadata and process that information as a System.ServiceModel.Description.MetadataSet, see System.ServiceModel.Description.MetadataExchangeClient.

The following code example shows the use of the MetadataResolver class to return metadata as a collection of ServiceEndpoint objects that are then used to connect to a service instance.

// 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();
  }
}

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();
  }
}

.NET Framework
Available since 3.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: