SoapDocumentMethodAttribute.Use Właściwość

Definicja

Pobiera lub ustawia formatowanie parametrów dla metody usługi sieci Web XML w części XML komunikatu 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

Wartość właściwości

SoapBindingUse

Metoda SoapBindingUse dla usługi sieci Web XML. Wartość domyślna to Literal.

Przykłady

Poniższy przykład kodu określa, że Document / Encoded komunikaty SOAP muszą być wysyłane do PlaceOrder metody usługi sieci Web 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

Uwagi

Język opisu usług sieci Web (WSDL) definiuje dwie metody formatowania parametrów: Encoded i Literal. Encoded odnosi się do parametrów formatowania przy użyciu kodowania SOAP, jak opisano w specyfikacji protokołu SOAP w sekcji 5. Literal Odwołuje się do formatowania parametrów przy użyciu wstępnie zdefiniowanego schematu XSD dla każdego parametru.

Aby uzyskać więcej informacji, zobacz Dostosowywanie formatowania komunikatów PROTOKOŁU SOAP.

Dotyczy

Zobacz też