更新 : 2007 年 11 月
サービス、コントラクト、およびエンドポイントの情報を、メタデータ ドキュメントに変換します。
名前空間 :
System.ServiceModel.Description
アセンブリ :
System.ServiceModel (System.ServiceModel.dll 内)
Public Class WsdlExporter _
Inherits MetadataExporter
Dim instance As WsdlExporter
public class WsdlExporter : MetadataExporter
public ref class WsdlExporter : public MetadataExporter
public class WsdlExporter extends MetadataExporter
public class WsdlExporter extends MetadataExporter
WsdlExporter クラスを使用して、ContractDescription または ServiceEndpoint オブジェクトを、MetadataSection オブジェクトによって表されるメタデータに変換します。
WsdlExporter は、3 つの手順からなるプロセスで使用されます。
ExportContract メソッド、ExportEndpoint メソッド、ExportEndpoints メソッドのいずれかを、適切なパラメータを指定して呼び出します。
基本の Errors プロパティを調べて、エクスポート エラーがあるかどうかを判断します。
エラーがない場合は、GetGeneratedMetadata を使用して、MetadataSection オブジェクトのコレクションを取得するか、GeneratedWsdlDocuments または GeneratedXmlSchemas プロパティを使用して、メタデータの具体的なバージョンを取得します。
IWsdlExportExtension インターフェイスを実装することによってカスタム WSDL 拡張のエクスポートをサポートできます。また、IPolicyExportExtension インターフェイスを実装することによってカスタム ポリシー アサーションのエクスポートをサポートできます。詳細については、それぞれのインターフェイスのドキュメントを参照してください。
メモ : |
|---|
WsdlExporter は、ContractDescription.GetContract メソッドを使用するか、ServiceHost インスタンスの ServiceDescription の一部として作成された ContractDescription インスタンスなど、共通言語ランタイム (CLR) の型情報を含む ContractDescription インスタンスからメタデータをエクスポートする場合にのみ使用できます。ContractDescription インスタンスをサービス メタデータからインポートした場合や、型情報を使用せずに作成した場合は、WsdlExporter を使用してメタデータをエクスポートできません。 |
ExportEndpoint メソッドを使用して、myServiceEndpoints と呼ばれる ServiceEndpoint オブジェクトのコレクション内のエンドポイントから一連の MetadataSection オブジェクトを生成する方法を次のコード例に示します。
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
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();
}
}
}
}
System..::.Object
System.ServiceModel.Description..::.MetadataExporter
System.ServiceModel.Description..::.WsdlExporter
この型のすべてのパブリック static (Visual Basic では Shared) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
Windows Vista, Windows XP SP2, Windows Server 2003
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
.NET Framework
サポート対象 : 3.5、3.0
参照