SoapMethodAttribute Clase

Definición

Personaliza el procesamiento y la generación SOAP para un método. Esta clase no puede heredarse.

public ref class SoapMethodAttribute sealed : System::Runtime::Remoting::Metadata::SoapAttribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public sealed class SoapMethodAttribute : System.Runtime.Remoting.Metadata.SoapAttribute
[System.AttributeUsage(System.AttributeTargets.Method)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class SoapMethodAttribute : System.Runtime.Remoting.Metadata.SoapAttribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type SoapMethodAttribute = class
    inherit SoapAttribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type SoapMethodAttribute = class
    inherit SoapAttribute
Public NotInheritable Class SoapMethodAttribute
Inherits SoapAttribute
Herencia
SoapMethodAttribute
Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar los miembros de la SoapMethodAttribute clase para personalizar la generación y el procesamiento de SOAP para un método.

#using <System.dll>
#using <System.Runtime.Remoting.dll>
using namespace System;
using namespace System::Runtime::Remoting::Metadata;

namespace ExampleNamespace
{
   public ref class ExampleClass
   {
   public:
      [SoapMethod(
         ResponseXmlElementName="ExampleResponseElement",
         ResponseXmlNamespace=
         "http://example.org/MethodResponseXmlNamespace",
         ReturnXmlElementName="HelloMessage",
         SoapAction="http://example.org/ExampleSoapAction#GetHello",
         XmlNamespace="http://example.org/MethodCallXmlNamespace")]
      String^ GetHello( String^ name )
      {
         return String::Format( L"Hello, {0}", name );
      }
   };

}

int main()
{
   
   // Get the method info object for the GetHello method.
   System::Reflection::MethodBase^ getHelloMethod = 
      ExampleNamespace::ExampleClass::typeid->GetMethod( L"GetHello" );
   
   // Print the XML namespace for the invocation of this method.
   String^ methodCallXmlNamespace =
      System::Runtime::Remoting::SoapServices::GetXmlNamespaceForMethodCall(
         getHelloMethod );
   Console::WriteLine( L"The XML namespace for the response of the method "
         L"GetHello in ExampleClass is {0}.", methodCallXmlNamespace );
   
   // Print the XML namespace for the response of this method.
   String^ methodResponseXmlNamespace =
      System::Runtime::Remoting::SoapServices::GetXmlNamespaceForMethodCall(
         getHelloMethod );
   Console::WriteLine( L"The XML namespace for the invocation of the method "
         L"GetHello in ExampleClass is {0}.", methodResponseXmlNamespace );
   
   // Print the SOAP action for this method.
   String^ getHelloSoapAction =
      System::Runtime::Remoting::SoapServices::GetXmlNamespaceForMethodCall(
         getHelloMethod );
   Console::WriteLine( L"The SOAP action for the method "
         L"GetHello in ExampleClass is {0}.", getHelloSoapAction );
}
using System;
using System.Runtime.Remoting.Metadata;

namespace ExampleNamespace
{
    public class ExampleClass
    {
        [SoapMethod(
             ResponseXmlElementName="ExampleResponseElement",
             ResponseXmlNamespace=
                "http://example.org/MethodResponseXmlNamespace",
             ReturnXmlElementName="HelloMessage",
             SoapAction="http://example.org/ExampleSoapAction#GetHello",
             XmlNamespace="http://example.org/MethodCallXmlNamespace")]
        public string GetHello(string name)
        {
            return "Hello, " + name;
        }
    }
}

public class Demo
{
    public static void Main(string[] args)
    {
        // Get the method info object for the GetHello method.
        System.Reflection.MethodBase getHelloMethod =
            typeof(ExampleNamespace.ExampleClass).GetMethod("GetHello");

        // Print the XML namespace for the invocation of this method.
        string methodCallXmlNamespace =
            System.Runtime.Remoting.SoapServices.
                GetXmlNamespaceForMethodCall(getHelloMethod);
        Console.WriteLine(
            "The XML namespace for the response of the method " +
            "GetHello in ExampleClass is {0}.",
            methodCallXmlNamespace);

        // Print the XML namespace for the response of this method.
        string methodResponseXmlNamespace =
            System.Runtime.Remoting.SoapServices.
                GetXmlNamespaceForMethodResponse(getHelloMethod);
        Console.WriteLine(
            "The XML namespace for the invocation of the method " +
            "GetHello in ExampleClass is {0}.",
            methodResponseXmlNamespace);

        // Print the SOAP action for this method.
        string getHelloSoapAction =
            System.Runtime.Remoting.SoapServices.
                GetSoapActionFromMethodBase(getHelloMethod);
        Console.WriteLine(
            "The SOAP action for the method " +
            "GetHello in ExampleClass is {0}.",
            getHelloSoapAction);
    }
}

Comentarios

Los objetos de destino para el SoapMethodAttribute atributo son métodos que se pueden invocar de forma remota. SoapMethodAttribute Aplique para personalizar la generación y el procesamiento de SOAP. Las propiedades de este atributo permiten al programador personalizar el campo de encabezado HTTP SOAPAction para indicar la intención de la solicitud HTTP SOAP.

Constructores

SoapMethodAttribute()

Crea una instancia de SoapMethodAttribute.

Campos

ProtXmlNamespace

Espacio de nombres XML donde se serializa el destino del atributo SOAP actual.

(Heredado de SoapAttribute)
ReflectInfo

Objeto de reflexión utilizado por las clases de atributos que se derivan de la clase SoapAttribute para establecer información de serialización XML.

(Heredado de SoapAttribute)

Propiedades

Embedded

Obtiene o establece un valor que indica si debe anidarse el tipo durante la serialización SOAP.

(Heredado de SoapAttribute)
ResponseXmlElementName

Obtiene o establece el nombre del elemento XML utilizado para la respuesta de método en el método de destino.

ResponseXmlNamespace

Obtiene o establece el espacio de nombres del elemento XML utilizado para la respuesta de método en el método de destino.

ReturnXmlElementName

Obtiene o establece el nombre del elemento XML utilizado para el valor devuelto por el método de destino.

SoapAction

Obtiene o establece el campo de encabezado SOAPAction utilizado con las solicitudes HTTP enviadas con este método. Esta propiedad no está implementada en la actualidad.

TypeId

Cuando se implementa en una clase derivada, obtiene un identificador único para este Attribute.

(Heredado de Attribute)
UseAttribute

Obtiene o establece un valor que indica si el destino del atributo actual se serializará como un atributo XML en vez de como un campo XML.

XmlNamespace

Obtiene o establece el espacio de nombres XML utilizado durante la serialización de llamadas de método remoto del método de destino.

Métodos

Equals(Object)

Devuelve un valor que indica si esta instancia es igual que un objeto especificado.

(Heredado de Attribute)
GetHashCode()

Devuelve el código hash de esta instancia.

(Heredado de Attribute)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
IsDefaultAttribute()

Si se reemplaza en una clase derivada, indica si el valor de esta instancia es el valor predeterminado de la clase derivada.

(Heredado de Attribute)
Match(Object)

Cuando se invalida en una clase derivada, devuelve un valor que indica si esta instancia es igual a un objeto especificado.

(Heredado de Attribute)
MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Implementaciones de interfaz explícitas

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío.

(Heredado de Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Obtiene la información de tipos de un objeto, que puede utilizarse para obtener la información de tipos de una interfaz.

(Heredado de Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1).

(Heredado de Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Proporciona acceso a las propiedades y los métodos expuestos por un objeto.

(Heredado de Attribute)

Se aplica a