SoapDocumentMethodAttribute.Use 属性

定义

获取或设置 SOAP 消息的 XML 部分中的 XML Web services 方法的参数格式设置。

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 services 方法的 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 消息格式

适用于

另请参阅