แก้ไข

แชร์ผ่าน


MetadataExporter Class

Definition

Exports service description information into metadata.

public ref class MetadataExporter abstract
public abstract class MetadataExporter
type MetadataExporter = class
Public MustInherit Class MetadataExporter
Inheritance
MetadataExporter
Derived

Examples

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

Remarks

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.

Properties

Errors

Gets a collection of errors that occurred during metadata export.

PolicyVersion

Specifies the version of WS-Policy specification being used.

State

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

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
ExportContract(ContractDescription)

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

ExportEndpoint(ServiceEndpoint)

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

ExportPolicy(ServiceEndpoint)

Converts policy assertions into a PolicyConversionContext object.

GetGeneratedMetadata()

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

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to