SoapMethodAttribute Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Personnalise la génération et le traitement SOAP pour une méthode. Cette classe ne peut pas être héritée.
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
- Héritage
- Attributs
Exemples
L’exemple de code suivant montre comment utiliser les membres de la classe pour personnaliser la génération et le SoapMethodAttribute traitement SOAP pour une méthode.
#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);
}
}
Remarques
Les objets cibles de l’attribut SoapMethodAttribute sont des méthodes qui peuvent être appelées à distance. Appliquez la commande pour personnaliser la génération et le SoapMethodAttribute traitement SOAP. Les propriétés de cet attribut permettent au programmeur de personnaliser le champ d’en-tête HTTP SOAPAction pour indiquer l’intention de la requête HTTP SOAP.
Constructeurs
| Nom | Description |
|---|---|
| SoapMethodAttribute() |
Crée une instance de SoapMethodAttribute. |
Champs
| Nom | Description |
|---|---|
| ProtXmlNamespace |
Espace de noms XML auquel la cible de l’attribut SOAP actuel est sérialisée. (Hérité de SoapAttribute) |
| ReflectInfo |
Objet de réflexion utilisé par les classes d’attributs dérivées de la SoapAttribute classe pour définir des informations de sérialisation XML. (Hérité de SoapAttribute) |
Propriétés
| Nom | Description |
|---|---|
| Embedded |
Obtient ou définit une valeur indiquant si le type doit être imbriqué pendant la sérialisation SOAP. (Hérité de SoapAttribute) |
| ResponseXmlElementName |
Obtient ou définit le nom de l’élément XML à utiliser pour la réponse de méthode à la méthode cible. |
| ResponseXmlNamespace |
Obtient ou définit l’espace de noms d’élément XML utilisé pour la réponse de méthode à la méthode cible. |
| ReturnXmlElementName |
Obtient ou définit le nom d’élément XML utilisé pour la valeur de retour de la méthode cible. |
| SoapAction |
Obtient ou définit le champ d’en-tête SOAPAction utilisé avec les requêtes HTTP envoyées avec cette méthode. Cette propriété n’est actuellement pas implémentée. |
| TypeId |
En cas d’implémentation dans une classe dérivée, obtient un identificateur unique pour cette Attribute. (Hérité de Attribute) |
| UseAttribute |
Obtient ou définit une valeur indiquant si la cible de l’attribut actuel sera sérialisée en tant qu’attribut XML au lieu d’un champ XML. |
| XmlNamespace |
Obtient ou définit l’espace de noms XML utilisé lors de la sérialisation des appels de méthode distante de la méthode cible. |
Méthodes
| Nom | Description |
|---|---|
| Equals(Object) |
Retourne une valeur qui indique si cette instance est égale à un objet spécifié. (Hérité de Attribute) |
| GetHashCode() |
Retourne le code de hachage pour cette instance. (Hérité de Attribute) |
| GetType() |
Obtient la Type de l’instance actuelle. (Hérité de Object) |
| IsDefaultAttribute() |
En cas de substitution dans une classe dérivée, indique si la valeur de cette instance est la valeur par défaut de la classe dérivée. (Hérité de Attribute) |
| Match(Object) |
En cas de substitution dans une classe dérivée, retourne une valeur qui indique si cette instance est égale à un objet spécifié. (Hérité de Attribute) |
| MemberwiseClone() |
Crée une copie superficielle du Objectactuel. (Hérité de Object) |
| ToString() |
Retourne une chaîne qui représente l’objet actuel. (Hérité de Object) |
Implémentations d’interfaces explicites
| Nom | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Mappe un jeu de noms avec un jeu correspondant d'identificateurs de dispatch. (Hérité de Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Récupère les informations de type d’un objet, qui peuvent être utilisées pour obtenir les informations de type d’une interface. (Hérité de Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Récupère le nombre d'interfaces d'informations de type fourni par un objet (0 ou 1). (Hérité de Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Fournit l’accès aux propriétés et méthodes exposées par un objet. (Hérité de Attribute) |