Düzenle

Aracılığıyla paylaş


WsdlExporter Class

Definition

Converts service, contract, and endpoint information into metadata documents.

public ref class WsdlExporter : System::ServiceModel::Description::MetadataExporter
public class WsdlExporter : System.ServiceModel.Description.MetadataExporter
type WsdlExporter = class
    inherit MetadataExporter
Public Class WsdlExporter
Inherits MetadataExporter
Inheritance
WsdlExporter

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.

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

Remarks

Use the WsdlExporter class to transform ContractDescription or ServiceEndpoint objects into metadata represented by MetadataSection objects.

The WsdlExporter is used in a three-step process.

  1. Call the ExportContract, ExportEndpoint, or ExportEndpoints method, passing the appropriate parameters.

  2. Determine whether there are any export errors by checking the base Errors property.

  3. If there are no errors, use the GetGeneratedMetadata to get a collection of MetadataSection objects or get more specific versions of the metadata using the GeneratedWsdlDocuments or GeneratedXmlSchemas properties.

You can support exporting custom WSDL extensions by implementing the IWsdlExportExtension interface and custom policy assertions by implementing the IPolicyExportExtension interface. For details, see the documentation for those interfaces.

Note

The WsdlExporter can only be used to export metadata from ContractDescription instances that contain Common Language Runtime (CLR) type information, such as a ContractDescription instance created using the ContractDescription.GetContract method or created as part of the ServiceDescription for a ServiceHost instance. You cannot use the WsdlExporter to export metadata from ContractDescription instances imported from service metadata or constructed without type information.

Constructors

WsdlExporter()

Initializes a new instance of the WsdlExporter class.

Properties

Errors

Gets a collection of errors that occurred during metadata export.

(Inherited from MetadataExporter)
GeneratedWsdlDocuments

Gets a collection of ServiceDescription objects after calling one of the export methods.

GeneratedXmlSchemas

Gets a set of XmlSchema objects after calling one of the export methods.

PolicyVersion

Specifies the version of WS-Policy specification being used.

(Inherited from MetadataExporter)
State

Gets a dictionary of objects used in the export of metadata.

(Inherited from MetadataExporter)

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
ExportContract(ContractDescription)

Exports metadata that describes only the contract information from the specified contract description.

ExportEndpoint(ServiceEndpoint)

Generates metadata about the specified endpoint.

ExportEndpoints(IEnumerable<ServiceEndpoint>, XmlQualifiedName)

Generates metadata about a group of endpoints from a specified service.

ExportPolicy(ServiceEndpoint)

Converts policy assertions into a PolicyConversionContext object.

(Inherited from MetadataExporter)
GetGeneratedMetadata()

Returns an enumerable collection of generated MetadataSection objects.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to