This documentation is archived and is not being maintained.

MetadataExchangeClient Class

Downloads service metadata.

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

public class MetadataExchangeClient
public class MetadataExchangeClient
public class MetadataExchangeClient
Not applicable.

Use the MetadataExchangeClient to download metadata. Typically, a MetadataExchangeClient is configured for a metadata request and then passed to the MetadataResolver.Resolve or MetadataResolver.Resolve method for the MetadataResolver to use to download metadata.

However, you can use the MetadataExchangeClient directly to retrieve metadata as a MetadataSet that contains MetadataSection objects.

Whether used directly or passed to a MetadataResolver, MetadataExchangeClient has the following members to control the metadata download process:

  • Use the constructors to customize the binding to use when making the metadata request.

  • Use the HttpCredentials property to specify the credentials used to make an HTTP/GET request.

  • Use the SoapCredentials property to specify the credentials used to make a WS-Transfer metadata request.

  • Use the MaximumResolvedReferences property to limit the number of metadata references the MetadataExchangeClient resolves.

  • Use the OperationTimeout property to limit the time spent retrieving metadata.

  • Use the ResolveMetadataReferences property to specify whether to locate and retrieve other metadata documents referred to by the metadata downloaded from the original metadata endpoint.

  • Use the GetMetadata methods to begin the downloading process.

In addition, you can create a derived class that can override the following two protected methods:

  • Override the GetChannelFactory method to modify the channel that makes a metadata request using WS-Transfer.

  • Override the GetWebRequest method to modify the HttpWebRequest that makes a metadata request using HTTP/GET.

The following code example shows the use of MetadataExchangeClient to specify a download binding, resolve any contained references to metadata, and download the metadata.

// Get metadata documents.
Console.WriteLine("URI of the metadata documents retreived:");
MetadataExchangeClient metaTransfer 
  = new MetadataExchangeClient(httpGetMetaAddress.Uri, MetadataExchangeClientMode.HttpGet);
metaTransfer.ResolveMetadataReferences = true;
MetadataSet otherDocs = metaTransfer.GetMetadata();
foreach (MetadataSection doc in otherDocs.MetadataSections)
  Console.WriteLine(doc.Dialect + " : " + doc.Identifier);


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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0