Export (0) Print
Expand All

SoapDocumentMethodAttribute Class

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

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

[AttributeUsageAttribute(AttributeTargets.Method)]
public sealed class SoapDocumentMethodAttribute : Attribute

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.

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="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;
 }

System.Object
  System.Attribute
    System.Web.Services.Protocols.SoapDocumentMethodAttribute

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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

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

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft