This documentation is archived and is not being maintained.

SoapDocumentMethodAttribute Class

Applying the SoapDocumentMethodAttribute to a method specifies that SOAP messages to and from the method use Document formatting.

For a list of all members of this type, see SoapDocumentMethodAttribute Members.


[Visual Basic]
NotInheritable Public Class SoapDocumentMethodAttribute
   Inherits Attribute
public sealed class SoapDocumentMethodAttribute : Attribute
public __gc __sealed class SoapDocumentMethodAttribute : public
class SoapDocumentMethodAttribute extends Attribute

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.


Web Services Description Language (WSDL) defines two styles for how an XML Web service method, which it calls an operation, can be formatted in a SOAP message: RPC and Document. Document refers to formatting the XML Web service method according to an XSD schema. The Document style refers to formatting the Body element as a series of one or more message parts following the Body element. Exactly how the individual message parts is determined by the Use and ParameterStyle properties. The Use property determines whether parameters are formatted Encoded or Literal. The ParameterStyle determines whether the parameters are encapsulated within a single message part following the Body element or whether each parameter is an individual message part.

For more details, see Customizing SOAP Messages

This attribute can be applied to both an XML Web service method on the server and a method of the proxy class on the client.


[Visual Basic, C#] The following code example sets the message style to Document for the GetUserName XML Web service method. Additionally, the XML element with the Body element for the SOAP request and SOAP response are set to GetUserNameRequest and GetUserNameResponse, respectively.

[Visual Basic] 
<%@ WebService Language="VB" class="MyUser" %>
Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols

Public Class MyUser
    Inherits WebService    
    <SoapDocumentMethod(Action := "", _
    RequestNamespace := "", _
    RequestElementName := "GetUserNameRequest", _
    ResponseNamespace := "", _
    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
            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

<%@ WebService Language="C#" class="MyUser" %>
 using System;
 using System.Web.Services;
 using System.Web.Services.Protocols;
 public class MyUser : WebService {
       [ SoapDocumentMethod(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;
           // 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 Language Filter in the upper-left corner of the page.


Namespace: System.Web.Services.Protocols

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

Assembly: System.Web.Services (in System.Web.Services.dll)

See Also

SoapDocumentMethodAttribute Members | System.Web.Services.Protocols Namespace | SoapDocumentServiceAttribute | SoapRpcMethodAttribute | SoapRpcServiceAttribute | SoapBindingUse | SoapParameterStyle