SoapMethodAttribute Classe
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Personaliza a geração e processamento de SOAP para um método. Esta classe não pode ser herdada.
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
- Herança
- Atributos
Exemplos
O exemplo de código seguinte mostra como usar os membros da SoapMethodAttribute classe para personalizar a geração e o processamento de SOAP para um 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);
}
}
Observações
Os objetos-alvo para o SoapMethodAttribute atributo são métodos que podem ser invocados remotamente. Aplicar o SoapMethodAttribute para personalizar a geração e processamento de SOAP. As propriedades deste atributo permitem ao programador personalizar o campo de cabeçalho HTTP SOAPAction para indicar a intenção do pedido HTTP SOAP.
Construtores
| Name | Description |
|---|---|
| SoapMethodAttribute() |
Cria uma instância de SoapMethodAttribute. |
Campos
| Name | Description |
|---|---|
| ProtXmlNamespace |
O espaço de nomes XML para o qual o destino do atributo SOAP atual é serializado. (Herdado de SoapAttribute) |
| ReflectInfo |
Um objeto de reflexão usado por classes de atributos derivadas da SoapAttribute classe para definir informação de serialização XML. (Herdado de SoapAttribute) |
Propriedades
| Name | Description |
|---|---|
| Embedded |
Recebe ou define um valor que indica se o tipo deve ser aninhado durante a serialização SOAP. (Herdado de SoapAttribute) |
| ResponseXmlElementName |
Obtém ou define o nome do elemento XML para usar na resposta do método ao método de destino. |
| ResponseXmlNamespace |
Obtém ou define o espaço de nomes dos elementos XML usados para a resposta do método ao método de destino. |
| ReturnXmlElementName |
Obtém ou define o nome do elemento XML usado para o valor de retorno do método alvo. |
| SoapAction |
Obtém ou define o campo de cabeçalho SOAPAction usado com pedidos HTTP enviados com este método. Esta propriedade ainda não está implementada. |
| TypeId |
Quando implementado numa classe derivada, obtém um identificador único para esta Attribute. (Herdado de Attribute) |
| UseAttribute |
Recebe ou define um valor que indica se o destino do atributo atual será serializado como um atributo XML em vez de um campo XML. |
| XmlNamespace |
Obtém ou define o espaço de nomes XML utilizado durante a serialização das chamadas remotas de método do método de destino. |
Métodos
| Name | Description |
|---|---|
| Equals(Object) |
Devolve um valor que indica se esta instância é igual a um objeto especificado. (Herdado de Attribute) |
| GetHashCode() |
Devolve o código de hash para esta instância. (Herdado de Attribute) |
| GetType() |
Obtém o Type da instância atual. (Herdado de Object) |
| IsDefaultAttribute() |
Quando sobrescrito numa classe derivada, indica se o valor desta instância é o valor padrão para a classe derivada. (Herdado de Attribute) |
| Match(Object) |
Quando sobrescrito numa classe derivada, devolve um valor que indica se esta instância é igual a um objeto especificado. (Herdado de Attribute) |
| MemberwiseClone() |
Cria uma cópia superficial do atual Object. (Herdado de Object) |
| ToString() |
Devolve uma cadeia que representa o objeto atual. (Herdado de Object) |
Implementações de Interface Explícita
| Name | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Mapeia um conjunto de nomes para um conjunto correspondente de identificadores de despacho. (Herdado de Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Recupera a informação de tipo de um objeto, que pode ser usada para obter a informação de tipo para uma interface. (Herdado de Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Recupera o número de interfaces de informações de tipo que um objeto fornece (0 ou 1). (Herdado de Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Proporciona acesso a propriedades e métodos expostos por um objeto. (Herdado de Attribute) |