SoapRpcMethodAttribute Class (System.Web.Services.Protocols)

Switch View :
ScriptFree
.NET Framework Class Library
SoapRpcMethodAttribute Class

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

Inheritance Hierarchy

System.Object
  System.Attribute
    System.Web.Services.Protocols.SoapRpcMethodAttribute

Namespace:  System.Web.Services.Protocols
Assembly:  System.Web.Services (in System.Web.Services.dll)
Syntax

Visual Basic
<AttributeUsageAttribute(AttributeTargets.Method)> _
Public NotInheritable Class SoapRpcMethodAttribute _
	Inherits Attribute
C#
[AttributeUsageAttribute(AttributeTargets.Method)]
public sealed class SoapRpcMethodAttribute : Attribute
Visual C++
[AttributeUsageAttribute(AttributeTargets::Method)]
public ref class SoapRpcMethodAttribute sealed : public Attribute
F#
[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Method)>]
type SoapRpcMethodAttribute =  
    class
        inherit Attribute
    end

The SoapRpcMethodAttribute type exposes the following members.

Constructors

  Name Description
Public method SoapRpcMethodAttribute() Initializes a new instance of the SoapRpcMethodAttribute class, setting all properties to their default values.
Public method SoapRpcMethodAttribute(String) Initializes a new instance of the SoapRpcMethodAttribute class, setting the Action property to the value of the action parameter.
Top
Properties

  Name Description
Public property Action Gets or sets the SOAPAction HTTP header field of the SOAP request.
Public property Binding Gets or sets the binding that an XML Web service method implements an operation for.
Public property OneWay Gets or sets whether an XML Web service client waits for the Web server to finish processing an XML Web service method.
Public property RequestElementName Gets or sets the XML element associated with the SOAP request for an XML Web service method.
Public property RequestNamespace Gets or sets the XML namespace associated with the SOAP request for an XML Web service method.
Public property ResponseElementName Gets or sets the XML element associated with the SOAP response for an XML Web service method.
Public property ResponseNamespace Gets or sets the XML namespace associated with the SOAP response for an XML Web service method.
Public property TypeId When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)
Public property Use Gets or sets the binding used when invoking the method.
Top
Methods

  Name Description
Public method Equals Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Returns the hash code for this instance. (Inherited from Attribute.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method IsDefaultAttribute When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Public method Match When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
Explicit Interface Implementations

  Name Description
Explicit interface implemetation Private method _Attribute.GetIDsOfNames Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetation Private method _Attribute.GetTypeInfo Retrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetation Private method _Attribute.GetTypeInfoCount Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetation Private method _Attribute.Invoke Provides access to properties and methods exposed by an object. (Inherited from Attribute.)
Top
Remarks

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 [<topic://cpconCustomizingSOAPInASPNETWebServicesWebServiceClients>].

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 null.

Examples

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

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

        ' 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 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;

           // 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;
 }



Version Information

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Thread Safety

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

Reference