SoapExtensionAttribute クラス
アセンブリ: System.Web.Services (system.web.services.dll 内)


ASP.NET で作成された XML Web サービス メソッドに属性を適用して、その XML Web サービス メソッドが SOAP 拡張機能と共に実行されるように設定できます。カスタム拡張機能属性を XML Web サービス メソッドまたはプロキシ クラス クライアントのメソッドに追加すると、ASP.NET は関連する拡張機能を適切なときに呼び出します。拡張機能属性は、SoapExtensionAttribute から派生するカスタム属性クラスです。派生した属性は、ExtensionType プロパティをオーバーライドして、属性と関連付けられている拡張機能の型を返す必要があります。

SoapExtensionAttribute から派生した次の TraceExtensionAttribute クラスは、XML Web サービス メソッドまたは XML Web サービス クライアント プロキシ クラスのメソッドへの属性の適用をサポートします。XML Web サービス メソッドまたは XML Web サービス クライアント プロキシ クラスのメソッドへ属性が適用されると、TraceExtension SOAP 拡張機能がそのメソッドと共に実行されます。
' Create a SoapExtensionAttribute for a SOAP extension that can be ' applied to an XML Web service method. <AttributeUsage(AttributeTargets.Method)> _ Public Class TraceExtensionAttribute Inherits SoapExtensionAttribute Private m_filename As String = "c:\log.txt" Private m_priority As Integer ' Return the type of 'TraceExtension' class. Public Overrides ReadOnly Property ExtensionType() As Type Get Return GetType(TraceExtension) End Get End Property ' User can set priority of the 'TraceExtension'. Public Overrides Property Priority() As Integer Get Return m_priority End Get Set(ByVal Value As Integer) m_priority = value End Set End Property Public Property Filename() As String Get Return m_filename End Get Set(ByVal Value As String) m_filename = value End Set End Property End Class
// Create a SoapExtensionAttribute for a SOAP extension that can be // applied to an XML Web service method. [AttributeUsage(AttributeTargets.Method)] public class TraceExtensionAttribute : SoapExtensionAttribute { private string myFilename; private int myPriority; // Set the name of the log file were SOAP messages will be stored. public TraceExtensionAttribute() : base() { myFilename = "C:\\logClient.txt"; } // Return the type of 'TraceExtension' class. public override Type ExtensionType { get { return typeof(TraceExtension); } } // User can set priority of the 'SoapExtension'. public override int Priority { get { return myPriority; } set { myPriority = value; } } public string Filename { get { return myFilename; } set { myFilename = value; } } }
// Create a SoapExtensionAttribute for a SOAP extension that can be // applied to an XML Web service method. [AttributeUsage(AttributeTargets::Method)] public ref class TraceExtensionAttribute: public SoapExtensionAttribute { private: String^ myFilename; int myPriority; public: // Set the name of the log file were SOAP messages will be stored. TraceExtensionAttribute() : SoapExtensionAttribute() { myFilename = "C:\\logClient.txt"; } property Type^ ExtensionType { // Return the type of 'TraceExtension' class. virtual Type^ get() override { return TraceExtension::typeid; } } property int Priority { // User can set priority of the 'SoapExtension'. virtual int get() override { return myPriority; } virtual void set( int value ) override { myPriority = value; } } property String^ Filename { String^ get() { return myFilename; } void set( String^ value ) { myFilename = value; } } };
// Create a SoapExtensionAttribute for a SOAP extension that can be // applied to an XML Web service method. /** @attribute AttributeUsage(AttributeTargets.Method) */ public class TraceExtensionAttribute extends SoapExtensionAttribute { private String myFilename; private int myPriority; // Set the name of the log file were SOAP messages will be stored. public TraceExtensionAttribute() { myFilename = "C:\\logClient.txt"; } //TraceExtensionAttribute // Return the type of 'TraceExtension' class. public Type get_ExtensionType() { return TraceExtension.class.ToType(); } //get_ExtensionType // User can set priority of the 'SoapExtension'. public int get_Priority() { return myPriority; } //get_Priority public void set_Priority(int value) { myPriority = value; } //set_Priority public String get_Filename() { return myFilename; } //get_Filename public void set_Filename(String value) { myFilename = value; } //set_Filename } //TraceExtensionAttribute

System.Attribute
System.Web.Services.Protocols.SoapExtensionAttribute


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SoapExtensionAttribute クラスのページへのリンク