SoapExtensionAttribute 類別

定義

當在衍生類別中覆寫時,指定 SOAP 擴充應該使用 XML Web Service 方法來執行。

public ref class SoapExtensionAttribute abstract : Attribute
public abstract class SoapExtensionAttribute : Attribute
type SoapExtensionAttribute = class
    inherit Attribute
Public MustInherit Class SoapExtensionAttribute
Inherits Attribute
繼承
SoapExtensionAttribute

範例

下列 TraceExtensionAttribute 類別衍生自 SoapExtensionAttribute ,以支援將 屬性套用至 XML Web 服務方法或 XML Web 服務用戶端 Proxy 類別中的方法。 套用至其中一個時, TraceExtension SOAP 擴充功能會使用 方法執行。

// 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.
[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 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

備註

您可以使用 ASP.NET 建立的 XML Web 服務方法,藉由將屬性套用至 XML Web 服務方法,以使用 SOAP 擴充功能進行設定。 將自訂延伸模組屬性新增至 XML Web 服務方法或用戶端 Proxy 類別上的 方法時,ASP.NET 適當時間叫用相關聯的延伸模組。 擴充屬性是衍生自 SoapExtensionAttribute 的自訂屬性類別。 衍生屬性必須覆寫 屬性, ExtensionType 才能傳回與 屬性相關聯的延伸類型。

建構函式

SoapExtensionAttribute()

初始化 SoapExtensionAttribute 類別的新執行個體。

屬性

ExtensionType

在衍生類別中覆寫時,取得 SOAP 擴充的 Type

Priority

在衍生類別中覆寫時,取得或設定 SOAP 擴充的優先權。

TypeId

在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。

(繼承來源 Attribute)

方法

Equals(Object)

傳回值,這個值指出此執行個體是否與指定的物件相等。

(繼承來源 Attribute)
GetHashCode()

傳回這個執行個體的雜湊碼。

(繼承來源 Attribute)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IsDefaultAttribute()

在衍生類別中覆寫時,表示這個執行個體的值是衍生類別的預設值。

(繼承來源 Attribute)
Match(Object)

在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。

(繼承來源 Attribute)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

(繼承來源 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。

(繼承來源 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。

(繼承來源 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。

(繼承來源 Attribute)

適用於

另請參閱