Condividi tramite


WsdlExporter.GetGeneratedMetadata Metodo

Definizione

Restituisce una raccolta enumerabile di oggetti MetadataSection generati.

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

Restituisce

Una raccolta enumerabile di oggetti MetadataSection generati che rappresentano i metadati generati come risultato di chiamate a ExportContract(ContractDescription), ExportEndpoint(ServiceEndpoint) o a ExportEndpoints(IEnumerable<ServiceEndpoint>, XmlQualifiedName).

Esempio

Nell'esempio di codice seguente viene illustrato come utilizzare il metodo ExportEndpoint per generare un set di oggetti MetadataSection dagli endpoint presenti in una raccolta di oggetti ServiceEndpoint chiamati 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

Commenti

Utilizzare la proprietà GetGeneratedMetadata per ottenere una raccolta di tutti i metadati generati come risultato di un numero indefinito di chiamate a ExportContract, ExportEndpoint o a ExportEndpoints.

Si consiglia di controllare la proprietà Errors di base per determinare se si sono verificati errori prima di recuperare i metadati.

Si applica a