Export (0) Print
Expand All

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)

[AttributeUsageAttribute(AttributeTargets.Method)] 
[ComVisibleAttribute(true)] 
public sealed class SoapMethodAttribute : SoapAttribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Method) */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class SoapMethodAttribute extends SoapAttribute
AttributeUsageAttribute(AttributeTargets.Method) 
ComVisibleAttribute(true) 
public final class SoapMethodAttribute extends SoapAttribute

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 System;
using System.Runtime.Remoting.Metadata;
using System.Security.Permissions;

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
{
[SecurityPermission(SecurityAction.Demand)]
    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);
    }
}

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 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft