Export (0) Print
Expand All

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.

  NameDescription
Public propertyErrorsGets a collection of errors that occurred during metadata export.
Public propertyPolicyVersionSpecifies the version of WS-Policy specification being used.
Public propertyStateGets a dictionary of objects used in the export of metadata.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodExportContractWhen overridden in a derived class, exports a contract description into metadata.
Public methodExportEndpointWhen overridden in a derived class, converts an endpoint into metadata.
Protected methodExportPolicyConverts policy assertions into a System.ServiceModel.Description.PolicyConversionContext object.
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetGeneratedMetadataWhen overridden in a derived class, returns the metadata generated by a call to either ExportContract, ExportEndpoint, or ExportPolicy.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns 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 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();

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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.
Show:
© 2014 Microsoft