.NET Framework Class Library
SoapDocumentMethodAttribute Class

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

Inheritance Hierarchy
SystemObject
   SystemAttribute
    System.Web.Services.ProtocolsSoapDocumentMethodAttribute

Namespace:   System.Web.Services.Protocols
Assembly:  System.Web.Services (in System.Web.Services.dll)
Syntax
<[%$TOPIC/60whx7y7_en-us_VS_110_2_0_0_0_0%]([%$TOPIC/60whx7y7_en-us_VS_110_2_0_0_0_1%].Method)> _
Public NotInheritable Class SoapDocumentMethodAttribute _
	Inherits [%$TOPIC/60whx7y7_en-us_VS_110_2_0_0_0_2%]
[[%$TOPIC/60whx7y7_en-us_VS_110_2_0_1_0_0%]([%$TOPIC/60whx7y7_en-us_VS_110_2_0_1_0_1%].Method)]
public sealed class SoapDocumentMethodAttribute : [%$TOPIC/60whx7y7_en-us_VS_110_2_0_1_0_2%]
[[%$TOPIC/60whx7y7_en-us_VS_110_2_0_2_0_0%]([%$TOPIC/60whx7y7_en-us_VS_110_2_0_2_0_1%]::Method)]
public ref class SoapDocumentMethodAttribute sealed : public [%$TOPIC/60whx7y7_en-us_VS_110_2_0_2_0_2%]
[<[%$TOPIC/60whx7y7_en-us_VS_110_2_0_3_0_0%]>]
[<[%$TOPIC/60whx7y7_en-us_VS_110_2_0_3_0_1%]([%$TOPIC/60whx7y7_en-us_VS_110_2_0_3_0_2%].Method)>]
type SoapDocumentMethodAttribute =  
    class 
        inherit [%$TOPIC/60whx7y7_en-us_VS_110_2_0_3_0_3%] 
    end

The SoapDocumentMethodAttribute type exposes the following members.

Constructors
  NameDescription
Public method SoapDocumentMethodAttributeInitializes a new instance of the SoapDocumentMethodAttribute class.
Public method SoapDocumentMethodAttribute(String)Initializes a new instance of the SoapDocumentMethodAttribute class, setting the Action property to the value of the action parameter.
Top
Properties
  NameDescription
Public property ActionGets or sets the SOAPAction HTTP header field of the SOAP request.
Public property BindingGets or sets the binding an XML Web service method is implementing an operation for.
Public property OneWayGets or sets whether an XML Web service client waits for the Web server to finish processing an XML Web service method.
Public property ParameterStyleGets or sets whether parameters are encapsulated within a single XML element beneath the Body element in the XML portion of a SOAP message.
Public property RequestElementNameGets or sets the XML element associated with the SOAP request for an XML Web service method, which is defined in a service description as an operation.
Public property RequestNamespaceGets or sets the namespace associated with the SOAP request for an XML Web service method.
Public property ResponseElementNameGets or sets the XML element associated with the SOAP response for an XML Web service method.
Public property ResponseNamespaceGets or sets the XML namespace associated with the SOAP response for an XML Web service method.
Public property TypeIdWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)
Public property UseGets or sets the parameter formatting for an XML Web service method within the XML portion of a SOAP message.
Top
Methods
  NameDescription
Public method EqualsInfrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Public method GetHashCodeReturns the hash code for this instance. (Inherited from Attribute.)
Public method GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method IsDefaultAttributeWhen 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 MatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Public method ToStringReturns a string that represents the current object. (Inherited from Object.)
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implemetation Private method _AttributeGetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetation Private method _AttributeGetTypeInfoRetrieves 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 _AttributeGetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetation Private method _AttributeInvokeProvides 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, 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 [<topic://cpconCustomizingSOAPInASPNETWebServicesWebServiceClients>]

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.

Examples

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.

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

Public Class MyUser
    Inherits WebService    

    <SoapDocumentMethod(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
<%@ WebService Language="C#" class="MyUser" %>
 using System;
 using System.Web.Services;
 using System.Web.Services.Protocols;

 public class MyUser : WebService {

       [ SoapDocumentMethod(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;
 }
Version Information

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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.