MetadataExporter Class

Exports service description information into metadata.

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

public abstract class MetadataExporter

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);
}
else
  xsdDCExporter = (XsdDataContractExporter)dataContractExporter;
if (xsdDCExporter.Options == null)
  xsdDCExporter.Options = new ExportOptions();
xsdDCExporter.Options.DataContractSurrogate = new DCAnnotationSurrogate();

System.Object
  System.ServiceModel.Description.MetadataExporter
    System.ServiceModel.Description.WsdlExporter

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 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft