WsdlExporter.GetGeneratedMetadata Метод

Определение

Возвращает перечисляемую коллекцию созданных объектов MetadataSection.

public:
 override System::ServiceModel::Description::MetadataSet ^ GetGeneratedMetadata();
public override System.ServiceModel.Description.MetadataSet GetGeneratedMetadata ();
override this.GetGeneratedMetadata : unit -> System.ServiceModel.Description.MetadataSet
Public Overrides Function GetGeneratedMetadata () As MetadataSet

Возвращаемое значение

Перечисляемая коллекция созданных объектов MetadataSection, которая представляет метаданные, созданные в результате вызовов ExportContract(ContractDescription), ExportEndpoint(ServiceEndpoint) или ExportEndpoints(IEnumerable<ServiceEndpoint>, XmlQualifiedName).

Примеры

В следующем примере кода показано, как использовать метод ExportEndpoint для создания набора объектов MetadataSection из конечных точек в коллекции объектов ServiceEndpoint с именем 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();
            }
        }
    }
}
Imports System.ServiceModel
Imports System.ServiceModel.Description

Module Module1

    Sub Main()
        Dim exporter As New WsdlExporter()
        exporter.PolicyVersion = PolicyVersion.Policy15

        Dim myServiceEndpoints() As ServiceEndpoint = New ServiceEndpoint(1) {}
        Dim myDescription As 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.
        For Each endpoint As ServiceEndpoint In myServiceEndpoints
            exporter.ExportEndpoint(endpoint)
        Next

        'If there are no errors, get the documents.
        Dim metadataDocs As MetadataSet
        metadataDocs = Nothing

        If (exporter.Errors.Count = 0) Then
            metadataDocs = exporter.GetGeneratedMetadata()
        End If
    End Sub

End Module

Комментарии

Используйте свойство GetGeneratedMetadata для возвращения коллекции всех метаданных, созданных в результате любого количества вызовов ExportContract, ExportEndpoint или ExportEndpoints.

Рекомендуется проверить базовое свойство Errors, чтобы определить наличие возникших ошибок перед получением метаданных.

Применяется к