This documentation is archived and is not being maintained.

SoapMethodAttribute Class

Customizes SOAP generation and processing for a method. This class cannot be inherited.

Namespace:  System.Runtime.Remoting.Metadata
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
<AttributeUsageAttribute(AttributeTargets.Method)> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class SoapMethodAttribute _
	Inherits SoapAttribute
'Usage
Dim instance As SoapMethodAttribute

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.

No code example is currently available or this language may not be supported.
#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.Object
  System.Attribute
    System.Runtime.Remoting.Metadata.SoapAttribute
      System.Runtime.Remoting.Metadata.SoapMethodAttribute

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: