SoapMethodAttribute Class
Customizes SOAP generation and processing for a method. This class cannot be inherited.
Assembly: mscorlib (in mscorlib.dll)
The target objects for the SoapMethodAttribute attribute are methods that can be remotely invoked. Apply the SoapMethodAttribute to customize SOAP generation and processing. Properties of this attribute allow the programmer to customize the SOAPAction HTTP header field to indicate the intent of the SOAP HTTP request.
The following code example shows how to use the members in the SoapMethodAttribute class to customize SOAP generation and processing for a method.
#using <mscorlib.dll>
#using <System.dll>
#using <System.Runtime.Remoting.dll>
using namespace System;
using namespace System::Runtime::Remoting::Metadata;
namespace ExampleNamespace
{
public __gc class ExampleClass
{
public:
[SoapMethod(
ResponseXmlElementName=S"ExampleResponseElement",
ResponseXmlNamespace=
S"http://example.org/MethodResponseXmlNamespace",
ReturnXmlElementName=S"HelloMessage",
SoapAction=S"http://example.org/ExampleSoapAction#GetHello",
XmlNamespace=S"http://example.org/MethodCallXmlNamespace")]
String* GetHello(String* name)
{
return String::Format( S"Hello, {0}", name );
}
};
}
int main()
{
// Get the method info object for the GetHello method.
System::Reflection::MethodBase* getHelloMethod =
__typeof(ExampleNamespace::ExampleClass)->GetMethod(S"GetHello");
// Print the XML namespace for the invocation of this method.
String* methodCallXmlNamespace =
System::Runtime::Remoting::SoapServices::
GetXmlNamespaceForMethodCall(getHelloMethod);
Console::WriteLine(
S"The XML namespace for the response of the method "
S"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(
S"The XML namespace for the invocation of the method "
S"GetHello in ExampleClass is {0}.",
methodResponseXmlNamespace);
// Print the SOAP action for this method.
String* getHelloSoapAction =
System::Runtime::Remoting::SoapServices::
GetSoapActionFromMethodBase(getHelloMethod);
Console::WriteLine(
S"The SOAP action for the method "
S"GetHello in ExampleClass is {0}.",
getHelloSoapAction);
}
System.Attribute
System.Runtime.Remoting.Metadata.SoapAttribute
System.Runtime.Remoting.Metadata.SoapMethodAttribute
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
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.