This topic has not yet been rated - Rate this topic

MetadataExporter Class

Exports service description information into metadata.

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

Namespace:  System.ServiceModel.Description
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
public abstract class MetadataExporter

The MetadataExporter type exposes the following members.

  Name Description
Public property Errors Gets a collection of errors that occurred during metadata export.
Public property PolicyVersion Specifies the version of WS-Policy specification being used.
Public property State Gets a dictionary of objects used in the export of metadata.
Top
  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public method ExportContract When overridden in a derived class, exports a contract description into metadata.
Public method ExportEndpoint When overridden in a derived class, converts an endpoint into metadata.
Protected method ExportPolicy Converts policy assertions into a System.ServiceModel.Description.PolicyConversionContext object.
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetGeneratedMetadata When overridden in a derived class, returns the metadata generated by a call to either ExportContract, ExportEndpoint, or ExportPolicy.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top

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


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Missing part of sentence
In the "Remarks" paragraph, a part at the end of the sentence "The System.ServiceModel.Description.WsdlExporter type is the implementation of the MetadataExporter class included with ." is missing.