SoapRpcMethodAttribute.Action Property

Definition

Gets or sets the SOAPAction HTTP header field of the SOAP request.

C#
public string Action { get; set; }

Property Value

The SOAPAction HTTP header field of the SOAP request. The default is http://tempuri.org/MethodName where MethodName is the name of the XML Web service method.

Examples

The following code example sets the Action property to http://www.contoso.com/Sample.

ASP.NET (C#)
<%@ 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;
 }

Remarks

Typically, the Action property is a URI indicating the intent of the SOAP request. However, the SOAP specification places no restrictions on the format and whether the URI refers to an existing document. 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.

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. The supported SOAP binding is SOAP 1.1.

For more information, see the SOAP specification on the W3C website.

Applies to

Proizvod Verzije
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1