SoapDocumentMethodAttribute.Use 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
在 SOAP 訊息的 XML 部分中取得或設定 XML Web 服務方法的參數格式。
public:
property System::Web::Services::Description::SoapBindingUse Use { System::Web::Services::Description::SoapBindingUse get(); void set(System::Web::Services::Description::SoapBindingUse value); };
public System.Web.Services.Description.SoapBindingUse Use { get; set; }
member this.Use : System.Web.Services.Description.SoapBindingUse with get, set
Public Property Use As SoapBindingUse
屬性值
這是 SoapBindingUse 針對 XML Web 服務方法的。 預設值為 Literal。
範例
以下程式碼範例指定 Document / Encoded SOAP 訊息必須傳送至 PlaceOrder XML Web 服務方法。
<%@ WebService Language="C#" Class="ShoppingCart" %>
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Services.Description;
using System;
public class ShoppingCart
{
[ SoapDocumentMethod(Use=SoapBindingUse.Encoded) ]
[ WebMethod]
public void PlaceOrder(OrderItem O)
{
// Process the order on the back end.
}
}
public class OrderItem
{
public int Count;
public int Description;
public DateTime OrderDate;
public long CustomerID;
public Decimal Cost;
}
<%@ WebService Language="VB" Class="ShoppingCart" %>
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Web.Services.Description
Imports System
Public Class ShoppingCart
' Specify that the XML Web service method uses encoded SOAP messages.
<SoapDocumentMethod(Use:=SoapBindingUse.Encoded), _
WebMethod()> _
Public Sub PlaceOrder(O as OrderItem)
' Process the order on the back end.
End Sub
End Class
Public Class OrderItem
Public Count As Integer
Public Description as String
Public OrderDate as DateTime
Public CustomerID as Long
Public Cost as Decimal
End Class
備註
網路服務描述語言(WSDL)定義了兩種參數格式化的方法: Encoded 與 Literal。 Encoded 指的是使用 SOAP 編碼來設定格式參數,詳見第 5 節的 SOAP 規範。 Literal 指的是使用預先定義的 XSD 結構來格式化參數。
更多細節請參閱 「自訂 SOAP 訊息格式化」。