WsdlExporter.GetGeneratedMetadata Method

Definition

Returns an enumerable collection of generated MetadataSection objects.

C#
public override System.ServiceModel.Description.MetadataSet GetGeneratedMetadata();

Returns

An enumerable collection of generated MetadataSection objects that represents the metadata generated as a result of calls to ExportContract(ContractDescription), ExportEndpoint(ServiceEndpoint), or ExportEndpoints(IEnumerable<ServiceEndpoint>, XmlQualifiedName).

Examples

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.

C#
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();
            }
        }
    }
}

Remarks

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.

Applies to

Produit Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1