SoapServices.GetTypeAndMethodNameFromSoapAction(String, String, String) 方法
定义
确定与指定的 SOAPAction 值关联的方法的类型和方法名。Determines the type and method name of the method associated with the specified SOAPAction value.
public:
static bool GetTypeAndMethodNameFromSoapAction(System::String ^ soapAction, [Runtime::InteropServices::Out] System::String ^ % typeName, [Runtime::InteropServices::Out] System::String ^ % methodName);
public static bool GetTypeAndMethodNameFromSoapAction (string soapAction, out string typeName, out string methodName);
static member GetTypeAndMethodNameFromSoapAction : string * string * string -> bool
Public Shared Function GetTypeAndMethodNameFromSoapAction (soapAction As String, ByRef typeName As String, ByRef methodName As String) As Boolean
参数
- soapAction
- String
为其请求类型和方法名的方法的 SOAPAction。The SOAPAction of the method for which the type and method names were requested.
- typeName
- String
当此方法返回时,该参数包含保存了相关方法的类型名称的 String。When this method returns, contains a String that holds the type name of the method in question. 此参数未经初始化即被传递。This parameter is passed uninitialized.
- methodName
- String
当此方法返回时,该参数包含保存了相关方法的方法名的 String。When this method returns, contains a String that holds the method name of the method in question. 此参数未经初始化即被传递。This parameter is passed uninitialized.
返回
如果类型和方法名成功恢复,则为 true;否则为 false。true if the type and method name were successfully recovered; otherwise, false.
例外
SOAPAction 值不以引号开头和结尾。The SOAPAction value does not start and end with quotes.
直接调用方没有基础结构权限。The immediate caller does not have infrastructure permission.
示例
下面的代码示例演示如何使用此方法。The following code example shows how to use this method. 此代码示例是为类提供的更大示例的一部分 SoapServices 。This code example is part of a larger example provided for the SoapServices class.
// 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 =
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);
注解
true 如果类型和方法名称查找成功,则为;否则为 false 。true if the type and method name lookups were successful; otherwise, false.