SoapRpcMethodAttribute.Action Property
Gets or sets the SOAPAction HTTP header field of the SOAP request.
[Visual Basic] Public Property Action As String [C#] public string Action {get; set;} [C++] public: __property String* get_Action(); public: __property void set_Action(String*); [JScript] public function get Action() : String; public function set Action(String);
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.
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, or no restrictions 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 about the SOAP specification, see the W3C Web site (http://www.w3.org/TR/SOAP).
Example
[Visual Basic, C#] The following code example sets the Action property to http://www.contoso.com/Sample.
[Visual Basic] <%@ 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 ' Deterime 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 [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; // Deterime 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; }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
See Also
SoapRpcMethodAttribute Class | SoapRpcMethodAttribute Members | System.Web.Services.Protocols Namespace