The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MetadataExporter Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Exports service description information into metadata.

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


public abstract class MetadataExporter


Gets a collection of errors that occurred during metadata export.


Specifies the version of WS-Policy specification being used.


Gets a dictionary of objects used in the export of metadata.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


When overridden in a derived class, exports a contract description into metadata.


When overridden in a derived class, converts an endpoint into metadata.


Converts policy assertions into a System.ServiceModel.Description.PolicyConversionContext object.


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


When overridden in a derived class, returns the metadata generated by a call to either ExportContract, ExportEndpoint, or ExportPolicy.


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

Metadata export is the process of describing service endpoints and projecting them into a parallel, standardized representation (typically, but not necessarily XML) that applications can access to implement a client that uses the service. To export metadata from System.ServiceModel.Description.ServiceEndpoint objects, use an implementation of the MetadataExporter abstract class. A MetadataExporter implementation generates metadata that is encapsulated in a System.ServiceModel.Description.MetadataSet instance.

The MetadataExporter class provides a framework for generating policy expressions that describe the capabilities and requirements of an endpoint binding and its associated operations, messages and faults. These policy expressions are captured in a System.ServiceModel.Description.PolicyConversionContext instance. A MetadataExporter implementation can then attach these policy expressions to the metadata it generates.

The MetadataExporter calls into each System.ServiceModel.Channels.BindingElement that implements the System.ServiceModel.Description.IPolicyExportExtension interface in the binding of a ServiceEndpoint when generating a PolicyConversionContext object for the MetadataExporter implementation to use. You can export new policy assertions by implementing the IPolicyExportExtension interface on your custom implementations of the System.ServiceModel.Channels.BindingElement type.

The System.ServiceModel.Description.WsdlExporter type is the implementation of the MetadataExporter class included with Windows Communication Foundation (WCF). The WsdlExporter type generates WSDL metadata with attached policy expressions.

To export custom WSDL metadata or WSDL extensions for endpoint behaviors, contract behaviors or binding elements in a service endpoint, you can implement the System.ServiceModel.Description.IWsdlExportExtension interface. The WsdlExporter type calls into parts of a service endpoint that implement this interface when generating the WSDL document from that endpoint.

The following code example is an IWsdlExportExtension.ExportContract method that demonstrates how the State property of the class WsdlExporter is used to attach a custom System.Runtime.Serialization.XsdDataContractExporter that modifies the export of data contracts in the endpoint.

  public void ExportContract(WsdlExporter exporter, WsdlContractConversionContext context)
// Add a custom DCAnnotationSurrogate to write data contract comments into the XSD.
object dataContractExporter;
XsdDataContractExporter xsdDCExporter;
if (!exporter.State.TryGetValue(typeof(XsdDataContractExporter), out dataContractExporter))
  xsdDCExporter = new XsdDataContractExporter(exporter.GeneratedXmlSchemas);
  exporter.State.Add(typeof(XsdDataContractExporter), xsdDCExporter);
  xsdDCExporter = (XsdDataContractExporter)dataContractExporter;
if (xsdDCExporter.Options == null)
  xsdDCExporter.Options = new ExportOptions();
xsdDCExporter.Options.DataContractSurrogate = new DCAnnotationSurrogate();

.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