Share via


SoapDocumentMethodAttribute.Use 屬性

定義

取得或設定 SOAP 訊息的 XML 部分內 XML Web Service 方法的參數格式。

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

屬性值

XML Web Service 方法的 SoapBindingUse。 預設為 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

備註

Web 服務描述語言 (WSDL) 會定義兩個格式化參數的方法: EncodedLiteralEncoded 指的是使用 SOAP 編碼來格式化參數,如第 5 節中的 SOAP 規格中所述。 Literal 是指使用每個參數預先定義的 XSD 架構來格式化參數。

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

適用於

另請參閱