SoapDocumentMethodAttribute.ParameterStyle 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定參數是否封裝在 SOAP 訊息中 XML 部分元素下方 Body 的單一 XML 元素中。
public:
property System::Web::Services::Protocols::SoapParameterStyle ParameterStyle { System::Web::Services::Protocols::SoapParameterStyle get(); void set(System::Web::Services::Protocols::SoapParameterStyle value); };
public System.Web.Services.Protocols.SoapParameterStyle ParameterStyle { get; set; }
member this.ParameterStyle : System.Web.Services.Protocols.SoapParameterStyle with get, set
Public Property ParameterStyle As SoapParameterStyle
屬性值
用於 SoapParameterStyle 傳送與 XML Web 服務方法的 SOAP 訊息。 預設值為 Wrapped。
範例
以下程式碼範例規定,發送至 PlaceOrder XML Web 服務方法的 SOAP 訊息中,所傳送的參數不會封裝在同一個 XML 元素中。
<%@ WebService Language="C#" Class="ShoppingCart" %>
using System.Web.Services;
using System.Web.Services.Protocols;
using System;
public class ShoppingCart
{
// Specify that parameters are not encapsulated within one XML element.
[ SoapDocumentMethod(ParameterStyle=SoapParameterStyle.Bare) ]
[ WebMethod]
public void PlaceOrder(OrderItem OrderDetails)
{
// 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
Public Class ShoppingCart
' Specify that parameters are not encapsulated within one XML element.
<SoapDocumentMethod(ParameterStyle:=SoapParameterStyle.Bare), _
WebMethod()> _
Public Sub PlaceOrder(OrderDetails 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