SoapDocumentMethodAttribute.Action Właściwość

Definicja

Pobiera lub ustawia SOAPAction pole nagłówka HTTP żądania SOAP.

public:
 property System::String ^ Action { System::String ^ get(); void set(System::String ^ value); };
public string Action { get; set; }
member this.Action : string with get, set
Public Property Action As String

Wartość właściwości

String

Pole SOAPAction nagłówka HTTP żądania SOAP. Wartość domyślna to http://tempuri.org/MethodName, gdzie MethodName jest nazwą metody usługi sieci Web XML.

Przykłady

Poniższy przykład kodu ustawia Action właściwość na http://www.contoso.com/GetUserName.

<%@ WebService Language="C#" class="MyUser" %>
 
 using System.Web.Services;
 using System.Web.Services.Protocols;
 
 public class MyUser : WebService {
 
      [ SoapDocumentMethod(Action="http://www.contoso.com/GetUserName")]
      public string GetUserName() {
       return User.Identity.Name;
      }
 }
<%@ WebService Language="VB" class="MyUser" %>

Imports System.Web.Services
Imports System.Web.Services.Protocols

Public Class MyUser
    Inherits WebService
        
    <SoapDocumentMethod(Action := "http://www.contoso.com/GetUserName")> _
    Public Function _
        GetUserName() As String
        
        Return User.Identity.Name
    End Function
End Class

Uwagi

Action Zazwyczaj właściwość jest identyfikatorem URI wskazującym intencję żądania. Jednak specyfikacja protokołu SOAP nie nakłada żadnych ograniczeń na format identyfikatora URI ani żadnych reguł dotyczących tego, czy identyfikator URI jest rozpoznawalny. Obecność i zawartość Action właściwości mogą być używane przez serwery sieci Web, takie jak zapory, w celu odpowiedniego filtrowania komunikatów żądań PROTOKOŁU SOAP w protokole HTTP.

Domyślnie .NET Framework w wersji 1.1 publikuje Action właściwość w atrybucie elementu dla każdego obsługiwanego soap:operation powiązania PROTOKOŁU SOAP w soapAction dokumentach WSDL generowanych dla usługi sieci Web XML. Aby uzyskać więcej informacji, zobacz specyfikację protokołu SOAP w witrynie internetowej W3C.

Dotyczy