クリックして評価とフィードバックをお寄せください
MSDN
MSDN ライブラリ
.NET 開発
.NET Framework 3.5
.NET Framework 3.5
 ExportContract メソッド

  低帯域幅での表示をオンにする
このページは次のバージョンについて記述しています。
Microsoft Visual Studio 2008/.NET Framework 3.5

その他のバージョンについては、以下の情報を参照してください。
.NET Framework クラス ライブラリ
IWsdlExportExtension..::.ExportContract メソッド

更新 : 2007 年 11 月

コントラクトに対して生成される Web サービス記述言語 (WSDL) に、カスタム WSDL 要素を書き込みます。

名前空間 :  System.ServiceModel.Description
アセンブリ :  System.ServiceModel (System.ServiceModel.dll 内)
Visual Basic (宣言)
Sub ExportContract ( _
    exporter As WsdlExporter, _
    context As WsdlContractConversionContext _
)
Visual Basic (使用法)
Dim instance As IWsdlExportExtension
Dim exporter As WsdlExporter
Dim context As WsdlContractConversionContext

instance.ExportContract(exporter, context)
C#
void ExportContract(
    WsdlExporter exporter,
    WsdlContractConversionContext context
)
Visual C++
void ExportContract(
    WsdlExporter^ exporter, 
    WsdlContractConversionContext^ context
)
J#
void ExportContract(
    WsdlExporter exporter,
    WsdlContractConversionContext context
)
JScript
function ExportContract(
    exporter : WsdlExporter, 
    context : WsdlContractConversionContext
)

パラメータ

exporter
型 : System.ServiceModel.Description..::.WsdlExporter
コントラクト情報をエクスポートする WsdlExporter
context
型 : System.ServiceModel.Description..::.WsdlContractConversionContext
エクスポートされた WSDL 要素からコントラクトの説明へのマッピングを提供します。

ExportContract メソッドは、メタデータ エクスポート システムがコントラクトをエクスポートするときに呼び出されます。IWsdlExportExtension を実装している操作の動作だけが ExportContract の呼び出しを受け取ります。IWsdlExportExtension を実装しているすべての動作が ExportEndpoint の呼び出しを受け取ります。

context パラメータを使用して、エクスポートする WSDL を変更します。例については、「使用例」のセクションを参照してください。

カスタム ドキュメント属性を WSDL ファイルに WSDL 注釈として追加する IWsdlExportExtension を次のコード例に示します。

C#
    public void ExportContract(WsdlExporter exporter, WsdlContractConversionContext context)
        {


...


      Console.WriteLine("Inside ExportContract");
            if (context.Contract != null)
            {
        // Inside this block it is the contract-level comment attribute.
        // This.Text returns the string for the contract attribute.
        // Set the doc element; if this isn't done first, there is no XmlElement in the 
        // DocumentElement property.
        context.WsdlPortType.Documentation = string.Empty; 
        // Contract comments.
        XmlDocument owner = context.WsdlPortType.DocumentationElement.OwnerDocument;
        XmlElement summaryElement = Formatter.CreateSummaryElement(owner, this.Text); 
        context.WsdlPortType.DocumentationElement.AppendChild(summaryElement);

        foreach (OperationDescription op in context.Contract.Operations)
        {
          Operation operation = context.GetOperation(op);
          object[] opAttrs = op.SyncMethod.GetCustomAttributes(typeof(WsdlDocumentationAttribute), false);
          if (opAttrs.Length == 1)
          {
            string opComment = ((WsdlDocumentationAttribute)opAttrs[0]).Text;

            // This.Text returns the string for the operation-level attributes.
            // Set the doc element; if this isn't done first, there is no XmlElement in the 
            // DocumentElement property.
            operation.Documentation = String.Empty;

            // Operation C# triple comments.
            XmlDocument opOwner = operation.DocumentationElement.OwnerDocument;
            XmlElement newSummaryElement = Formatter.CreateSummaryElement(opOwner, opComment);
            operation.DocumentationElement.AppendChild(newSummaryElement);

            // Get returns information
            ParameterInfo returnValue = op.SyncMethod.ReturnParameter;
            object[] returnAttrs = returnValue.GetCustomAttributes(typeof(WsdlParameterDocumentationAttribute), false);
            if (returnAttrs.Length == 1)
            {
              // <returns>text.</returns>
              XmlElement returnsElement = 
                Formatter.CreateReturnsElement(
                  opOwner,
                  ((WsdlParameterDocumentationAttribute)returnAttrs[0]).ParamComment
                );
              operation.DocumentationElement.AppendChild(returnsElement);
            }

            // Get parameter information.
            ParameterInfo[] args = op.SyncMethod.GetParameters();
            for (int i = 0; i < args.Length; i++)
            {
              object[] docAttrs 
                = args[i].GetCustomAttributes(typeof(WsdlParameterDocumentationAttribute), false);
              if (docAttrs.Length != 0)
              {
                // <param name="Int1">Text.</param>
                XmlElement newParamElement = opOwner.CreateElement("param");
                XmlAttribute paramName = opOwner.CreateAttribute("name");
                paramName.Value = args[i].Name;
                newParamElement.InnerText 
                  = ((WsdlParameterDocumentationAttribute)docAttrs[0]).ParamComment;
                newParamElement.Attributes.Append(paramName);
                operation.DocumentationElement.AppendChild(newParamElement);
              }
            }
          }
        }
      }

  • 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

Windows Vista, Windows XP SP2, Windows Server 2003

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。

.NET Framework

サポート対象 : 3.5、3.0
コミュニティ コンテンツ   コミュニティ コンテンツとは
新しいコンテンツの追加 RSS  注釈
Processing
© 2009 Microsoft Corporation. All rights reserved. 使用条件  |  商標  |  プライバシー
Page view tracker