SoapRpcMethodAttribute Class

Specifies that SOAP messages sent to and from the method use RPC formatting.

Namespace: System.Web.Services.Protocols
Assembly: System.Web.Services (in

public sealed class SoapRpcMethodAttribute : Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Method) */ 
public final class SoapRpcMethodAttribute extends Attribute
public final class SoapRpcMethodAttribute extends Attribute
Not applicable.

Web Services Description Language (WSDL) defines two styles for how an XML Web service method, or operation, can be formatted in a SOAP message: RPC and Document. RPC formatting refers to formatting the operation according to the SOAP specification for using SOAP for RPC; otherwise known as Section 7 of the SOAP specification. RPC formatting states that all parameters are encapsulated within a single XML element named after the XML Web service method and that each XML element within that XML element represents a parameter named after the parameter it is representing.

SOAP messages formatted in both the RPC and Document styles can be used to communicate with an XML Web service in a Remote Procedure Call (RPC) manner; however the Document style can also easily be used to communicate in a loosely coupled manner. Therefore, Document style XML Web services is recommended. For more details, see the Customizing SOAP Messages topic.

For more details, see Customizing SOAP Message Formatting.

This attribute can be applied to an XML Web service method on the server and a proxy class on the client. XML Web service methods that have the OneWay property set to true do not have access to their HttpContext. As such, accessing any of the properties of the WebService class return a null reference (Nothing in Visual Basic).

The following code example sets the message style to Rpc for the GetUserName XML Web service method.

<%@ WebService Language="C#" class="MyUser" %>
 using System;
 using System.Web.Services;
 using System.Web.Services.Protocols;
 public class MyUser : WebService {
       [ SoapRpcMethod(Action="", 
      [ 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 out the domain name from 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;


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions