This documentation is archived and is not being maintained.

WsdlExporter Class

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

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

'Declaration
Public Class WsdlExporter _
	Inherits MetadataExporter
'Usage
Dim instance As WsdlExporter

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.

NoteNote:

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.

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.

Imports System
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

System.Object
  System.ServiceModel.Description.MetadataExporter
    System.ServiceModel.Description.WsdlExporter

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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
Show: