Retrieving Metadata

Metadata retrieval is the process of requesting and retrieving metadata from a metadata endpoint, such as a WS-MetadataExchange (MEX) metadata endpoint or an HTTP/GET metadata endpoint.

Retrieving Metadata from the Command Line Using Svcutil.exe

You can retrieve service metadata using WS-MetadataExchange or HTTP/GET requests by using the ServiceModel Metadata Utility Tool (Svcutil.exe) tool and passing the /target:metadata switch and an address. Svcutil.exe downloads the metadata at the specified address and saves the file to disk. Svcutil.exe uses a System.ServiceModel.Description.MetadataExchangeClient instance internally and loads from configuration the IMetadataExchange endpoint configuration whose name matches the scheme of the address passed to Svcutil.exe as input.

Retrieving Metadata Programmatically Using the MetadataExchangeClient

Windows Communication Foundation (WCF) can retrieve service metadata using standardized protocols such as WS-MetadataExchange and HTTP/GET requests. Both of these protocols are supported by the MetadataExchangeClient type. You retrieve service metadata using the System.ServiceModel.Description.MetadataExchangeClient type by providing an address for the metadata endpoint and an optional binding. The binding used by a System.ServiceModel.Description.MetadataExchangeClient instance can be one of the default bindings from the MetadataExchangeBindings static class, a user-supplied binding, or a binding loaded from an endpoint configuration for the IMetadataExchange contract. The System.ServiceModel.Description.MetadataExchangeClient can also resolve HTTP URL references to metadata using the HttpWebRequest type.

By default, a System.ServiceModel.Description.MetadataExchangeClient instance is tied to a single ChannelFactory instance. You can change or replace the System.ServiceModel.ChannelFactory instance used by a System.ServiceModel.Description.MetadataExchangeClient by overriding the GetChannelFactory virtual method. Similarly, you can change or replace the HttpWebRequest instance used by a System.ServiceModel.Description.MetadataExchangeClient to make HTTP/GET requests by overriding the System.ServiceModel.Description.MetadataExchangeClient.GetWebRequest(System.Uri,System.String,System.String) virtual method.

In This Section

See Also

Reference

MetadataExchangeClient