System.Runtime.Remoting.SoapServices.GetTypeAndMethodNameFromSoapAction C# (CSharp) Method

GetTypeAndMethodNameFromSoapAction() public static method

public static GetTypeAndMethodNameFromSoapAction ( String soapAction, String &typeName, String &methodName ) : bool
soapAction String
typeName String
methodName String
return bool
        public static bool GetTypeAndMethodNameFromSoapAction(String soapAction,
                                                              out String typeName,
                                                              out String methodName)
        {             
            // remove quotation marks if present
            if ((soapAction[0] == '"') && (soapAction[soapAction.Length - 1] == '"'))
                soapAction = soapAction.Substring(1, soapAction.Length - 2);

            ArrayList mbTable = (ArrayList)_soapActionToMethodBase[soapAction];
            if (mbTable != null)
            {
                // indicate that we can't resolve soap action to type and method name
                if (mbTable.Count > 1)
                {
                    typeName = null;
                    methodName = null;
                    return false;
                }
        
                MethodBase mb = (MethodBase)mbTable[0];
                if (mb != null)
                {
                    Type type = mb.DeclaringType;
                    typeName = type.FullName + ", " + type.Module.Assembly.nGetSimpleName();
                    methodName = mb.Name;
                    return true;
                }                
            }

    
            String[] parts = soapAction.Split(new char[1]{'#'});
            if (parts.Length == 2)
            {
                bool assemblyIncluded;
                typeName = XmlNamespaceEncoder.GetTypeNameForSoapActionNamespace(
                    parts[0], out assemblyIncluded);
                if (typeName == null)
                {
                    methodName = null;
                    return false;
                }

                methodName = parts[1];
                return true;
            }
            else
            {
                typeName = null;
                methodName = null;
                return false;
            }

        } // GetTypeAndMethodNameFromSoapAction

Usage Example

示例#1
0
        /// <summary>Determines if the specified SOAPAction is acceptable for a given <see cref="T:System.Reflection.MethodBase" />.</summary>
        /// <returns>true if the specified SOAPAction is acceptable for a given <see cref="T:System.Reflection.MethodBase" />; otherwise, false.</returns>
        /// <param name="soapAction">The SOAPAction to check against the given <see cref="T:System.Reflection.MethodBase" />. </param>
        /// <param name="mb">The <see cref="T:System.Reflection.MethodBase" /> the specified SOAPAction is checked against. </param>
        /// <exception cref="T:System.Security.SecurityException">The immediate caller does not have infrastructure permission. </exception>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
        /// </PermissionSet>
        public static bool IsSoapActionValidForMethodBase(string soapAction, MethodBase mb)
        {
            string a;
            string a2;

            SoapServices.GetTypeAndMethodNameFromSoapAction(soapAction, out a, out a2);
            if (a2 != mb.Name)
            {
                return(false);
            }
            string assemblyQualifiedName = mb.DeclaringType.AssemblyQualifiedName;

            return(a == assemblyQualifiedName);
        }