SoapMethodAttribute クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<AttributeUsageAttribute(AttributeTargets.Method)> _ <ComVisibleAttribute(True)> _ Public NotInheritable Class SoapMethodAttribute Inherits SoapAttribute
[AttributeUsageAttribute(AttributeTargets.Method)] [ComVisibleAttribute(true)] public sealed class SoapMethodAttribute : SoapAttribute
[AttributeUsageAttribute(AttributeTargets::Method)] [ComVisibleAttribute(true)] public ref class SoapMethodAttribute sealed : public SoapAttribute

SoapMethodAttribute 属性のターゲット オブジェクトは、リモートから呼び出すことができるメソッドです。SOAP 生成および SOAP 処理をカスタマイズするために SoapMethodAttribute を適用します。この属性のプロパティを使用すると、プログラマは SOAPAction HTTP ヘッダー フィールドをカスタマイズして、SOAP HTTP 要求の意図を示すことができます。

SoapMethodAttribute クラスのメンバを使用して、メソッドの SOAP 生成と処理をカスタマイズする方法を次のコード例に示します。
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); } }
#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 ); }

System.Attribute
System.Runtime.Remoting.Metadata.SoapAttribute
System.Runtime.Remoting.Metadata.SoapMethodAttribute


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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SoapMethodAttribute クラスのページへのリンク