WsdlExporter.GetGeneratedMetadata Method

Returns an enumerable collection of generated MetadataSection objects.

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

public override MetadataSet GetGeneratedMetadata()

Return Value

Type: System.ServiceModel.Description.MetadataSet
An enumerable collection of generated MetadataSection objects that represents the metadata generated as a result of calls to ExportContract, ExportEndpoint, or ExportEndpoints.

Use the GetGeneratedMetadata property to get a collection of all the metadata generated as a result of any number of calls to ExportContract, ExportEndpoint, or ExportEndpoints.

It is recommended that you check the base Errors property to determine whether any errors occurred before you retrieve the metadata.

The following code example shows how to use the ExportEndpoint method to generate a set of MetadataSection objects from the endpoints in a collection of ServiceEndpoint objects called myServiceEndpoints.

using System;
using System.ServiceModel;
using System.ServiceModel.Description;

namespace WsdlExporterSample
{
    class Program
    {
        static void Main(string[] args)
        {
            WsdlExporter exporter = new WsdlExporter();
            exporter.PolicyVersion = PolicyVersion.Policy15;

            ServiceEndpoint [] myServiceEndpoints = new ServiceEndpoint[2];
            ContractDescription myDescription = new ContractDescription ("myContract");
            myServiceEndpoints[0] = new ServiceEndpoint(myDescription,new BasicHttpBinding(),new EndpointAddress("http://localhost/myservice"));
            myServiceEndpoints[1] = new ServiceEndpoint(myDescription,new BasicHttpBinding(),new EndpointAddress("http://localhost/myservice"));

            // Export all endpoints for each endpoint in collection. 
            foreach (ServiceEndpoint endpoint in myServiceEndpoints)
            {
                exporter.ExportEndpoint(endpoint);
            }
            // If there are no errors, get the documents.
            MetadataSet metadataDocs = null;
            if (exporter.Errors.Count != 0)
            {
                metadataDocs = exporter.GetGeneratedMetadata();
            }
        }
    }
}

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