MetadataSection Class

Represents XML metadata or references to XML metadata.

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

public class MetadataSection
public class MetadataSection
public class MetadataSection
Not applicable.

The MetadataSection class conforms to the definition of the wsx:Metadata/wsx:MetadataSection element in the WS-Metadata Exchange specification and contains XML metadata or references to XML metadata.

A MetadataSection object contains one dialect of metadata in XML form (such as a Web Services Description Language or WSDL file). You can add a MetadataSection to a collection of XML metadata represented by a MetadataSet object. Much of the Windows Communication Foundation (WCF) metadata system, such as the MetadataExchangeClient class, use the MetadataSet class to import or export service metadata in XML form.

For example, to export WCF contract or endpoint objects to a MetadataSet object that contains the equivalent metadata in XML form, call the appropriate Export methods on the WsdlExporter class, passing either ContractDescription or ServiceEndpoint objects, and then call the GetGeneratedMetadata method.

To import XML-based metadata from a MetadataSet object into WCFContractDescription, ServiceEndpoint, and Binding objects, pass a MetadataSet object to the constructor of the WsdlImporter class and call one of the import methods.

The following code example shows how to retrieve the MetadataSection objects from a System.ServiceModel.Description.MetadataResolver and iterate through them to write the Identifier and Dialect properties to the console.

// Get metadata documents.
Console.WriteLine("URI of the metadata documents retreived:");
MetadataExchangeClient metaTransfer 
  = new MetadataExchangeClient(httpGetMetaAddress.Uri, MetadataExchangeClientMode.HttpGet);
metaTransfer.ResolveMetadataReferences = true;
MetadataSet otherDocs = metaTransfer.GetMetadata();
foreach (MetadataSection doc in otherDocs.MetadataSections)
  Console.WriteLine(doc.Dialect + " : " + doc.Identifier);


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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions