SoapDocumentServiceAttribute 類別

定義

將選擇性的 SoapDocumentServiceAttribute 套用於 XML Web Service,來設定傳送往返於 XML Web Service 內 XML Web Service 方法之 SOAP 要求和回應的預設格式。

public ref class SoapDocumentServiceAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class SoapDocumentServiceAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type SoapDocumentServiceAttribute = class
    inherit Attribute
Public NotInheritable Class SoapDocumentServiceAttribute
Inherits Attribute
繼承
SoapDocumentServiceAttribute
屬性

範例

<%@ WebService Language="c#" Class="SumService" %>

using System;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Services.Description;

    [SoapDocumentService(SoapBindingUse.Literal,
                         SoapParameterStyle.Wrapped,
                         RoutingStyle=SoapServiceRoutingStyle.SoapAction)]
    public class SumService : System.Web.Services.WebService
    {
        [WebMethod]
        public int Add(int a, int b)
        {
            return a + b;
        }
    }
<%@ WebService Language="VB" Class="SumService" %>

Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Web.Services.Description

    <SoapDocumentService(SoapBindingUse.Literal, _
                             SoapParameterStyle.Wrapped, _
                             RoutingStyle := SoapServiceRoutingStyle.SoapAction)> _
    Public Class SumService 
          Inherits System.Web.Services.WebService
    
        <WebMethod> _
        Public Function Add(a As Integer, b as Integer)
           return a + b
        End Function
    End Class

備註

SoapDocumentServiceAttribute可讓您設定 XML Web 服務內 XML Web 服務方法的預設格式樣式。 如果個別 XML Web 服務方法必須變更這些預設值,請將 套用 SoapDocumentMethodAttribute 至該 XML Web 服務方法。

Web 服務描述語言 (WSDL) 定義 XML Web 服務方法呼叫作業的兩種樣式,可以在 SOAP 要求或 SOAP 回應中格式化: RPCDocument 。 與 屬性確切決定 UseParameterStyle 個別訊息部分的方式。 屬性 Use 會決定參數是格式化 Encoded 還是 Literal 。 會 ParameterStyle 決定參數是否封裝在 專案底下的 Body 單一訊息元件內,或每個參數是否為個別訊息元件。

若要將預設方法層級格式設定為 RPC ,請將 套用 SoapRpcServiceAttribute 至實作 XML Web 服務的 類別。

如需詳細資訊,請參閱 自訂 SOAP 訊息格式

這個屬性可以套用至實作 XML Web 服務的類別。

建構函式

SoapDocumentServiceAttribute()

初始化 SoapDocumentServiceAttribute 類別的新執行個體,將所有屬性設定為它們的預設值。

SoapDocumentServiceAttribute(SoapBindingUse)

初始化 SoapDocumentServiceAttribute 類別的新執行個體,設定參數格式。

SoapDocumentServiceAttribute(SoapBindingUse, SoapParameterStyle)

初始化 SoapDocumentServiceAttribute 類別的新執行個體,設定參數格式並設定參數是否封裝於單一 XML 項目中,在 Body 項目底下、SOAP 訊息中。

屬性

ParameterStyle

取得或設定預設設定,控制參數是否封裝於單一項目 (在 XML Web Service 之 XML Web Service 方法的 SOAP 訊息 XML 部分中的 <Body> 項目之後) 中。

RoutingStyle

取得或設定 SOAP 訊息如何傳送至 XML Web Service。

TypeId

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

(繼承來源 Attribute)
Use

取得或設定 XML Web Service 的預設參數格式。

方法

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)

適用於

另請參閱