Versión imprimible       Enviar     
Evaluar y enviar comentarios
Contraer todo/Expandir todo Contraer todo
Esta página es específica de
Microsoft Visual Studio 2005/.NET Framework 2.0

Hay además otras versiones disponibles para:
SoapDocumentMethodAttribute (Clase)
Al aplicar SoapDocumentMethodAttribute a un método se especifica que los mensajes SOAP hacia y desde el método utilizan el formato Document.

Espacio de nombres: System.Web.Services.Protocols
Ensamblado: System.Web.Services (en system.web.services.dll)

Visual Basic (Declaración)
<AttributeUsageAttribute(AttributeTargets.Method)> _
Public NotInheritable Class SoapDocumentMethodAttribute
    Inherits Attribute
Visual Basic (Uso)
Dim instance As SoapDocumentMethodAttribute
C#
[AttributeUsageAttribute(AttributeTargets.Method)] 
public sealed class SoapDocumentMethodAttribute : Attribute
C++
[AttributeUsageAttribute(AttributeTargets::Method)] 
public ref class SoapDocumentMethodAttribute sealed : public Attribute
J#
/** @attribute AttributeUsageAttribute(AttributeTargets.Method) */ 
public final class SoapDocumentMethodAttribute extends Attribute
JScript
AttributeUsageAttribute(AttributeTargets.Method) 
public final class SoapDocumentMethodAttribute extends Attribute
XAML
No aplicable.

El Lenguaje de descripción de servicios Web (WSDL) define dos estilos para dar formato a un método de servicios Web XML, que denomina una operación, en un mensaje SOAP: RPC y Document. Document indica que se da formato a un método de servicios Web XML de acuerdo con un esquema XSD. El estilo Document indica que se da formato al elemento Body como una serie de partes de uno o varios mensajes que siguen al elemento Body. Las propiedades Use y ParameterStyle determinan exactamente las partes del mensaje. La propiedad Use determina si los parámetros tendrán el formato Encoded o Literal. ParameterStyle determina si los parámetros se encapsulan en una única parte de mensaje que sigue al elemento Body o si cada parámetro es una parte de mensaje individual.

Para obtener información más detallada, vea Personalizar el formato de los mensajes SOAP.

Este atributo se puede aplicar a un método de servicios Web XML del servidor o a un método de la clase de proxy del cliente.

En el siguiente ejemplo de código, se establece el estilo de mensaje en Document para el método de servicios Web XML GetUserName. Además, el elemento XML con el elemento Body para la solicitud SOAP y la respuesta SOAP se establecen en GetUserNameRequest y GetUserNameResponse, respectivamente.

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 := "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
C#
<%@ 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
Los miembros estáticos públicos (Shared en Visual Basic) de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.

Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Compatible con: 2.0, 1.0
© 2009 Microsoft Corporation. Reservados todos los derechos. Términos de uso | Marcas Registradas | Privacidad
Page view tracker