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
屬性值
SOAP 訊息的 SoapParameterStyle 傳送往返於 XML Web Service 方法。 預設值是 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