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

属性值

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 消息格式设置。

适用于

另请参阅