Freigeben über


SoapServices.GetSoapActionFromMethodBase-Methode

Gibt den SOAPAction-Wert zurück, der der Methode zugeordnet ist, die in der bestimmten MethodBase angegeben wurde.

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

Syntax

'Declaration
Public Shared Function GetSoapActionFromMethodBase ( _
    mb As MethodBase _
) As String
'Usage
Dim mb As MethodBase
Dim returnValue As String

returnValue = SoapServices.GetSoapActionFromMethodBase(mb)
public static string GetSoapActionFromMethodBase (
    MethodBase mb
)
public:
static String^ GetSoapActionFromMethodBase (
    MethodBase^ mb
)
public static String GetSoapActionFromMethodBase (
    MethodBase mb
)
public static function GetSoapActionFromMethodBase (
    mb : MethodBase
) : String

Parameter

  • mb
    Die MethodBase mit der Methode, für die eine SOAPAction angefordert ist.

Rückgabewert

Der SOAPAction-Wert, der der Methode zugeordnet ist, die in der bestimmten MethodBase angegeben wurde.

Ausnahmen

Ausnahmetyp Bedingung

SecurityException

Der direkte Aufrufer verfügt nicht über die Berechtigung für die Infrastruktur.

Hinweise

Wenn die angegebene MethodBase ohne SOAPAction-Wert registriert wurde, gibt die GetSoapActionFromMethodBase-Methode die SOAPAction zurück, die mit MethodBase automatisch zwischengespeichert wurde.

Beispiel

Im folgenden Codebeispiel wird die Verwendung dieser Methode veranschaulicht. Dieses Codebeispiel ist Teil eines umfangreicheren Beispiels für die SoapServices-Klasse.

// Get the SOAP action for the method.
System.Reflection.MethodBase getHelloMethodBase = 
    typeof(ExampleNamespace.ExampleClass).GetMethod("GetHello");
string getHelloSoapAction =
    SoapServices.GetSoapActionFromMethodBase(getHelloMethodBase);
Console.WriteLine(
    "The SOAP action for the method " +
    "ExampleClass.GetHello is {0}.", getHelloSoapAction);
bool isSoapActionValid = SoapServices.IsSoapActionValidForMethodBase(
    getHelloSoapAction,
    getHelloMethodBase);
if (isSoapActionValid)
{
    Console.WriteLine(
        "The SOAP action, {0}, " + 
        "is valid for ExampleClass.GetHello", 
        getHelloSoapAction);
}
else
{
    Console.WriteLine(
        "The SOAP action, {0}, " + 
        "is not valid for ExampleClass.GetHello", 
        getHelloSoapAction);
}

// Register the SOAP action for the GetHello method.
SoapServices.RegisterSoapActionForMethodBase(getHelloMethodBase);

// Get the type and the method names encoded into the SOAP action.
string encodedTypeName;
string encodedMethodName;
SoapServices.GetTypeAndMethodNameFromSoapAction(
    getHelloSoapAction, 
    out encodedTypeName, 
    out encodedMethodName);
Console.WriteLine(
    "The type name encoded in this SOAP action is {0}.",
    encodedTypeName);
Console.WriteLine(
    "The method name encoded in this SOAP action is {0}.",
    encodedMethodName);
// Get the SOAP action for the method.
System::Reflection::MethodBase^ getHelloMethodBase =
   ExampleNamespace::ExampleClass::typeid->GetMethod( L"GetHello" );
String^ getHelloSoapAction =
   SoapServices::GetSoapActionFromMethodBase( getHelloMethodBase );
Console::WriteLine( L"The SOAP action for the method "
L"ExampleClass.GetHello is {0}.", getHelloSoapAction );
bool isSoapActionValid =
   SoapServices::IsSoapActionValidForMethodBase(
      getHelloSoapAction, getHelloMethodBase );
if ( isSoapActionValid )
{
   Console::WriteLine( L"The SOAP action, {0}, "
   L"is valid for ExampleClass.GetHello", getHelloSoapAction );
}
else
{
   Console::WriteLine( L"The SOAP action, {0}, "
   L"is not valid for ExampleClass.GetHello", getHelloSoapAction );
}

// Register the SOAP action for the GetHello method.
SoapServices::RegisterSoapActionForMethodBase( getHelloMethodBase );

// Get the type and the method names encoded into the SOAP action.
String^ encodedTypeName;
String^ encodedMethodName;
SoapServices::GetTypeAndMethodNameFromSoapAction(
   getHelloSoapAction,encodedTypeName,encodedMethodName );
Console::WriteLine( L"The type name encoded in this SOAP action is {0}.",
   encodedTypeName );
Console::WriteLine( L"The method name encoded in this SOAP action is {0}.",
   encodedMethodName );
// Get the SOAP action for the method.
System.Reflection.MethodBase getHelloMethodBase = ExampleNamespace.
    ExampleClass.class.ToType().GetMethod("GetHello");
String getHelloSoapAction = SoapServices.
    GetSoapActionFromMethodBase(getHelloMethodBase);
Console.WriteLine("The SOAP action for the method " 
    + "ExampleClass.GetHello is {0}.", getHelloSoapAction);
boolean isSoapActionValid = SoapServices.
    IsSoapActionValidForMethodBase(getHelloSoapAction, 
    getHelloMethodBase);
if (isSoapActionValid) {
    Console.WriteLine("The SOAP action, {0}, " 
        + "is valid for ExampleClass.GetHello", getHelloSoapAction);
}
else {
    Console.WriteLine("The SOAP action, {0}, " 
        + "is not valid for ExampleClass.GetHello", getHelloSoapAction);
}
// Register the SOAP action for the GetHello method.
SoapServices.RegisterSoapActionForMethodBase(getHelloMethodBase);
// Get the type and the method names encoded into the SOAP action.
String encodedTypeName = "";
String encodedMethodName = "";
SoapServices.GetTypeAndMethodNameFromSoapAction(getHelloSoapAction, 
    encodedTypeName, encodedMethodName);
Console.WriteLine("The type name encoded in this SOAP action is {0}.", 
    encodedTypeName);
Console.WriteLine("The method name encoded in this SOAP action is {0}.", 
    encodedMethodName);

.NET Framework-Sicherheit

Plattformen

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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

SoapServices-Klasse
SoapServices-Member
System.Runtime.Remoting-Namespace