共用方式為


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訊息格式設定。

適用於

另請參閱