SoapDocumentMethodAttribute.Use Свойство

Определение

Получает или задает параметр форматирования метода веб-службы XML в XML-части сообщения SOAP.

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-веб-службы. Значение по умолчанию — Literal.

Примеры

В следующем примере кода указывается, что Document / Encoded сообщения SOAP должны отправляться методу PlaceOrder веб-службы XML.

<%@ 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

Комментарии

Язык описания веб-служб (WSDL) определяет два метода форматирования параметров: Encoded и Literal. Encoded относится к параметрам форматирования с использованием кодировки SOAP, как описано в спецификации SOAP в разделе 5. Literal относится к форматированию параметров с помощью предварительно определенной схемы XSD для каждого параметра.

Дополнительные сведения см. в разделе Настройка форматирования сообщений SOAP.

Применяется к

См. также раздел