更新 : 2007 年 11 月
カスタム WSDL エクスポータおよびカスタム WSDL インポータに渡され、コントラクトのメタデータのエクスポートおよびインポートのプロセスをカスタマイズできるようにします。
名前空間 :
System.ServiceModel.Description
アセンブリ :
System.ServiceModel (System.ServiceModel.dll 内)
Public Class WsdlContractConversionContext
Dim instance As WsdlContractConversionContext
public class WsdlContractConversionContext
public ref class WsdlContractConversionContext
public class WsdlContractConversionContext
public class WsdlContractConversionContext
WsdlContractConversionContext オブジェクトを使用して、WSDL との間で変換する項目を確認および変更します。
メタデータをエクスポートするとき、WsdlContractConversionContext オブジェクトは、ExportContract メソッドおよび ExportEndpoint メソッドに渡されます。さまざまなメソッドやプロパティを使用して、公開される WSDL を確認および変更するために使用できるメタデータ オブジェクトを取得します。
メタデータをインポートするとき、WsdlContractConversionContext オブジェクトは、ImportContract メソッドおよび ImportEndpoint メソッドに渡されます。さまざまなメソッドやプロパティを使用して、インポートされるメタデータを確認および変更するために使用できるメタデータ オブジェクトを取得します。
WsdlContractConversionContext を使用して、エクスポートされるメタデータに WsdlPortType プロパティおよび Contract プロパティを使用してカスタム WSDL 注釈を追加する方法を次の例に示します。
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);
}
}
}
}
}
System..::.Object
System.ServiceModel.Description..::.WsdlContractConversionContext
この型のすべてのパブリック 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
参照