SoapRpcMethodAttribute.Action Eigenschaft

Definition

Ruft das SOAPAction-HTTP-Headerfeld der SOAP-Anforderung ab oder legt dieses fest.Gets or sets the SOAPAction HTTP header field of the SOAP request.

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

Eigenschaftswert

String

Das SOAPAction-HTTP-Headerfeld der SOAP-Anforderung.The SOAPAction HTTP header field of the SOAP request. Der Standardwert ist, http://tempuri.org/MethodName wobei MethodName der Name der XML-Webdienst Methode ist.The default is http://tempuri.org/MethodName where MethodName is the name of the XML Web service method.

Beispiele

Im folgenden Codebeispiel wird die- Action Eigenschaft auf festgelegt http://www.contoso.com/Sample .The following code example sets the Action property to http://www.contoso.com/Sample.

<%@ WebService Language="C#" class="MyUser" %>
 using System;
 using System.Web.Services;
 using System.Web.Services.Protocols;
 
 public class MyUser : WebService {
 
       [ SoapRpcMethod(Action="http://www.contoso.com/Sample", 
           RequestNamespace="http://www.contoso.com/Request",
           RequestElementName="GetUserNameRequest",
           ResponseNamespace="http://www.contoso.com/Response",
           ResponseElementName="GetUserNameResponse")]
      [ WebMethod(Description="Obtains the User Name") ]
      public UserName GetUserName() {
           string temp;
           int pos;
           UserName NewUser = new UserName();
           
           // Get the full user name, including the domain name if applicable.
           temp = User.Identity.Name;
 
           // Determine whether the user is part of a domain by searching for a backslash.
           pos = temp.IndexOf("\\");
           
           // Parse the domain name out of the string, if one exists.
           if (pos <= 0)
                 NewUser.Name = User.Identity.Name;
           else {
               NewUser.Name = temp.Remove(0,pos+1);
                 NewUser.Domain = temp.Remove(pos,temp.Length-pos);
           } 
       return NewUser;
      }
 
 }   
 
 public class UserName {
 
     public string Name;
     public string Domain;
 }
<%@ WebService Language="VB" class="MyUser" %>
Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols

Public Class MyUser
    Inherits WebService    
    
    <SoapRpcMethod(Action := "http://www.contoso.com/Sample", _
    RequestNamespace := "http://www.contoso.com/Request", _
    RequestElementName := "GetUserNameRequest", _
    ResponseNamespace := "http://www.contoso.com/Response", _
    ResponseElementName := "GetUserNameResponse"), _
    WebMethod(Description := "Obtains the User Name")> _
    Public Function _
        GetUserName() As UserName
        
        Dim temp As String
        Dim pos As Integer
        Dim NewUser As New UserName()
        
        ' Get the full user name, including the domain name if applicable.
        temp = User.Identity.Name
        
        ' Determine whether the user is part of a domain by searching for a backslash.
        pos = temp.IndexOf("\")
        
        ' Parse the domain name out of the string, if one exists.
        If pos <= 0 Then
            NewUser.Name = User.Identity.Name
        Else
            NewUser.Name = temp.Remove(0, pos + 1)
            NewUser.Domain = temp.Remove(pos, temp.Length - pos)
        End If
        Return NewUser
    End Function
End Class 

Public Class UserName
    
    Public Name As String
    Public Domain As String
End Class

Hinweise

In der Regel Action handelt es sich bei der Eigenschaft um einen URI, der die Absicht der SOAP-Anforderung angibt.Typically, the Action property is a URI indicating the intent of the SOAP request. Die SOAP-Spezifikation legt jedoch keine Einschränkungen für das Format fest und gibt an, ob sich der URI auf ein vorhandenes Dokument bezieht.However, the SOAP specification places no restrictions on the format and whether the URI refers to an existing document. Die Anwesenheit und der Inhalt der- Action Eigenschaft können von Webservern wie Firewalls verwendet werden, um SOAP-Anforderungs Nachrichten in http ordnungsgemäß zu filtern.The presence and content of the Action property can be used by Web servers such as firewalls to appropriately filter SOAP request messages in HTTP.

Standardmäßig veröffentlicht die .NET Framework Version 1,1 die- Action Eigenschaft im- soapAction Attribut des- soap:operation Elements für jede unterstützte SOAP-Bindung in WSDL-Dokumenten, die für einen XML-Webdienst generiert werden.By default, the .NET Framework version 1.1 publishes the Action property in the soapAction attribute of the soap:operation element for each supported SOAP binding in WSDL documents generated for an XML Web service. Die unterstützte SOAP-Bindung ist SOAP 1,1.The supported SOAP binding is SOAP 1.1.

Weitere Informationen finden Sie in der SOAP -Spezifikation auf der W3C-Website.For more information, see the SOAP specification on the W3C website.

Gilt für: