Exemplo n.º 1
0
        internal override void SetReflectionObject(object reflectionObject)
        {
            MethodBase mb = (MethodBase)reflectionObject;

            if (_responseElement == null)
            {
                _responseElement = mb.Name + "Response";
            }

            if (_responseNamespace == null)
            {
                _responseNamespace = SoapServices.GetXmlNamespaceForMethodResponse(mb);
            }

            if (_returnElement == null)
            {
                _returnElement = "return";
            }

            if (_soapAction == null)
            {
                _soapAction = SoapServices.GetXmlNamespaceForMethodCall(mb) + "#" + mb.Name;
            }

            if (_namespace == null)
            {
                _namespace = SoapServices.GetXmlNamespaceForMethodCall(mb);
            }
        }
        // used by the client
        internal SoapMessage BuildSoapMessageFromMethodCall(
            IMethodCallMessage mcm,
            out ITransportHeaders requestHeaders)
        {
            requestHeaders = new TransportHeaders();
            SoapMessage soapMsg = new SoapMessage();

            GetInfoFromMethodCallMessage(mcm);

            // Format the SoapMessage that will be used to create the RPC
            soapMsg.MethodName = mcm.MethodName;
            //int count = mcm.ArgCount;
            ArrayList paramNames  = new ArrayList(_methodCallParameters.Length);
            ArrayList paramTypes  = new ArrayList(_methodCallParameters.Length);
            ArrayList paramValues = new ArrayList(_methodCallParameters.Length);

            // Add the function parameters to the SoapMessage class
            foreach (ParameterInfo paramInfo in _methodCallParameters)
            {
                if (!(paramInfo.IsOut && paramInfo.ParameterType.IsByRef))
                {
                    Type t = paramInfo.ParameterType;
                    if (t.IsByRef)
                    {
                        t = t.GetElementType();
                    }
                    paramNames.Add(paramInfo.Name);
                    paramTypes.Add(t);
                    paramValues.Add(mcm.Args[paramInfo.Position]);
                }
            }
            soapMsg.ParamNames   = (string[])paramNames.ToArray(typeof(string));
            soapMsg.ParamTypes   = (Type[])paramTypes.ToArray(typeof(Type));
            soapMsg.ParamValues  = (object[])paramValues.ToArray(typeof(object));
            soapMsg.XmlNameSpace = SoapServices.GetXmlNamespaceForMethodCall(_methodCallInfo);
            soapMsg.Headers      = BuildMessageHeaders(mcm);

            // Format the transport headers
            requestHeaders["Content-Type"] = "text/xml; charset=\"utf-8\"";
            requestHeaders["SOAPAction"]   = "\"" +
                                             SoapServices.GetSoapActionFromMethodBase(_methodCallInfo) + "\"";
            requestHeaders[CommonTransportKeys.RequestUri] = mcm.Uri;

            return(soapMsg);
        }
Exemplo n.º 3
0
        public virtual void GetObjectData(Object obj, SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            if ((obj != null) && (obj != _rootObj))
            {
                (new MessageSurrogate(_ss)).GetObjectData(obj, info, context);
            }
            else
            {
                IMethodReturnMessage msg = obj as IMethodReturnMessage;
                if (null != msg)
                {
                    if (msg.Exception == null)
                    {
                        String responseElementName;
                        String responseElementNS;
                        String returnElementName;

                        // obtain response element name namespace
                        MethodBase          mb   = msg.MethodBase;
                        SoapMethodAttribute attr = (SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute(mb);
                        responseElementName = attr.ResponseXmlElementName;
                        responseElementNS   = attr.ResponseXmlNamespace;
                        returnElementName   = attr.ReturnXmlElementName;

                        ArgMapper mapper = new ArgMapper(msg, true /*fOut*/);
                        Object[]  args   = mapper.Args;
                        info.FullTypeName = responseElementName;
                        info.AssemblyName = responseElementNS;
                        Type retType = ((MethodInfo)mb).ReturnType;
                        if (!((retType == null) || (retType == _voidType)))
                        {
                            info.AddValue(returnElementName, msg.ReturnValue, retType);
                        }
                        if (args != null)
                        {
                            Type[] types = mapper.ArgTypes;
                            for (int i = 0; i < args.Length; i++)
                            {
                                String name;
                                name = mapper.GetArgName(i);
                                if ((name == null) || (name.Length == 0))
                                {
                                    name = "__param" + i;
                                }
                                info.AddValue(
                                    name,
                                    args[i],
                                    types[i].IsByRef?
                                    types[i].GetElementType():types[i]);
                            }
                        }
                    }
                    else
                    {
                        Object oClientIsClr = CallContext.GetData("__ClientIsClr");
                        bool   bClientIsClr = (oClientIsClr == null) ? true:(bool)oClientIsClr;
                        info.FullTypeName = "FormatterWrapper";
                        info.AssemblyName = DefaultFakeRecordAssemblyName;

                        Exception     ex = msg.Exception;
                        StringBuilder sb = new StringBuilder();
                        bool          bMustUnderstandError = false;
                        while (ex != null)
                        {
                            if (ex.Message.StartsWith("MustUnderstand"))
                            {
                                bMustUnderstandError = true;
                            }

                            sb.Append(" **** ");
                            sb.Append(ex.GetType().FullName);
                            sb.Append(" - ");
                            sb.Append(ex.Message);

                            ex = ex.InnerException;
                        }

                        ServerFault serverFault = null;
                        if (bClientIsClr)
                        {
                            serverFault = new ServerFault(msg.Exception); // Clr is the Client use full exception
                        }
                        else
                        {
                            serverFault = new ServerFault(msg.Exception.GetType().AssemblyQualifiedName, sb.ToString(), msg.Exception.StackTrace);
                        }

                        String faultType = "Server";
                        if (bMustUnderstandError)
                        {
                            faultType = "MustUnderstand";
                        }

                        SoapFault soapFault = new SoapFault(faultType, sb.ToString(), null, serverFault);
                        info.AddValue("__WrappedObject", soapFault, _soapFaultType);
                    }
                }
                else
                {
                    IMethodCallMessage mcm = (IMethodCallMessage)obj;

                    // obtain method namespace
                    MethodBase mb = mcm.MethodBase;
                    String     methodElementNS = SoapServices.GetXmlNamespaceForMethodCall(mb);

                    Object[] args  = mcm.InArgs;
                    String[] names = GetInArgNames(mcm, args.Length);
                    Type[]   sig   = (Type[])mcm.MethodSignature;
                    info.FullTypeName = mcm.MethodName;
                    info.AssemblyName = methodElementNS;
                    RemotingMethodCachedData cache = (RemotingMethodCachedData)InternalRemotingServices.GetReflectionCachedData(mb);
                    int[] requestArgMap            = cache.MarshalRequestArgMap;


                    BCLDebug.Assert(
                        args != null || sig.Length == args.Length,
                        "Signature mismatch");

                    for (int i = 0; i < args.Length; i++)
                    {
                        String paramName = null;
                        if ((names[i] == null) || (names[i].Length == 0))
                        {
                            paramName = "__param" + i;
                        }
                        else
                        {
                            paramName = names[i];
                        }

                        int  sigPosition = requestArgMap[i];
                        Type argType     = null;

                        if (sig[sigPosition].IsByRef)
                        {
                            argType = sig[sigPosition].GetElementType();
                        }
                        else
                        {
                            argType = sig[sigPosition];
                        }

                        info.AddValue(paramName, args[i], argType);
                    }
                }
            }
        } // GetObjectData
Exemplo n.º 4
0
    public static void Main(string[] args)
    {
        //<snippet101>
        // Convert a CLR namespace and assembly name into an XML namespace.
        string xmlNamespace =
            SoapServices.CodeXmlNamespaceForClrTypeNamespace(
                "ExampleNamespace", "AssemblyName");

        Console.WriteLine("The name of the XML namespace is {0}.",
                          xmlNamespace);
        //</snippet101>

        //<snippet102>
        // Extract a CLR namespace and assembly name from an XML namespace.
        string typeNamespace;
        string assemblyName;

        SoapServices.DecodeXmlNamespaceForClrTypeNamespace(xmlNamespace,
                                                           out typeNamespace, out assemblyName);
        Console.WriteLine("The name of the CLR namespace is {0}.",
                          typeNamespace);
        Console.WriteLine("The name of the CLR assembly is {0}.",
                          assemblyName);
        //</snippet102>

        //<snippet103>
        // Get the XML element name and the XML namespace for
        // an Interop type.
        string xmlElement;
        bool   isSoapTypeAttribute =
            SoapServices.GetXmlElementForInteropType(
                typeof(ExampleNamespace.ExampleClass),
                out xmlElement, out xmlNamespace);

        // Print whether the requested value was flagged
        // with a SoapTypeAttribute.
        if (isSoapTypeAttribute)
        {
            Console.WriteLine(
                "The requested value was flagged " +
                "with the SoapTypeAttribute.");
        }
        else
        {
            Console.WriteLine(
                "The requested value was not flagged " +
                "with the SoapTypeAttribute.");
        }

        // Print the XML element and the XML namespace.
        Console.WriteLine(
            "The XML element for the type " +
            "ExampleNamespace.ExampleClass is {0}.",
            xmlElement);
        Console.WriteLine(
            "The XML namespace for the type " +
            "ExampleNamespace.ExampleClass is {0}.",
            xmlNamespace);
        //</snippet103>

        //<snippet104>
        // Get the XML type name and the XML type namespace for
        // an Interop type.
        string xmlTypeName;
        string xmlTypeNamespace;

        isSoapTypeAttribute =
            SoapServices.GetXmlTypeForInteropType(
                typeof(ExampleNamespace.ExampleClass),
                out xmlTypeName, out xmlTypeNamespace);

        // Print whether the requested value was flagged
        // with a SoapTypeAttribute.
        if (isSoapTypeAttribute)
        {
            Console.WriteLine(
                "The requested value was flagged " +
                "with the SoapTypeAttribute.");
        }
        else
        {
            Console.WriteLine(
                "The requested value was not flagged " +
                "with the SoapTypeAttribute.");
        }

        // Print the XML type name and the XML type namespace.
        Console.WriteLine(
            "The XML type for the type " +
            "ExampleNamespace.ExampleClass is {0}.",
            xmlTypeName);
        Console.WriteLine(
            "The XML type namespace for the type " +
            "ExampleNamespace.ExampleClass is {0}.",
            xmlTypeNamespace);
        //</snippet104>

        //<snippet105>
        // Print the XML namespace for a method invocation and its
        // response.
        System.Reflection.MethodBase getHelloMethod =
            typeof(ExampleNamespace.ExampleClass).GetMethod("GetHello");
        string methodCallXmlNamespace =
            SoapServices.GetXmlNamespaceForMethodCall(getHelloMethod);
        string methodResponseXmlNamespace =
            SoapServices.GetXmlNamespaceForMethodResponse(getHelloMethod);

        Console.WriteLine(
            "The XML namespace for the invocation of the method " +
            "GetHello in ExampleClass is {0}.",
            methodResponseXmlNamespace);
        Console.WriteLine(
            "The XML namespace for the response of the method " +
            "GetHello in ExampleClass is {0}.",
            methodCallXmlNamespace);
        //</snippet105>

        //<snippet106>
        // Determine whether an XML namespace represents a CLR namespace.
        string clrNamespace = SoapServices.XmlNsForClrType;

        if (SoapServices.IsClrTypeNamespace(clrNamespace))
        {
            Console.WriteLine(
                "The namespace {0} is a CLR namespace.",
                clrNamespace);
        }
        else
        {
            Console.WriteLine(
                "The namespace {0} is not a CLR namespace.",
                clrNamespace);
        }
        //</snippet106>

        //<snippet130>
        // Print the XML namespace for the CLR types.
        Console.WriteLine(
            "The XML namespace for the CLR types " +
            "is {0}.",
            SoapServices.XmlNsForClrType);
        //</snippet130>

        //<snippet131>
        // Print the XML namespace for the CLR types
        // that have an assembly but no common language runtime namespace.
        Console.WriteLine(
            "The XML namespace for the CLR types " +
            "that have an assembly but no namespace, is {0}.",
            SoapServices.XmlNsForClrTypeWithAssembly);
        //</snippet131>

        //<snippet132>
        // Print the XML namespace for the CLR types
        // that are a part of the Mscorlib.dll.
        Console.WriteLine(
            "The XML namespace for the CLR types " +
            "that are part of the Mscorlib.dll, is {0}.",
            SoapServices.XmlNsForClrTypeWithNs);
        //</snippet132>

        //<snippet133>
        // Print the XML namespace for the CLR types
        // that have both an assembly and a common language runtime
        // namespace.
        Console.WriteLine(
            "The XML namespace for the CLR types " +
            "that have both an assembly and a namespace, is {0}.",
            SoapServices.XmlNsForClrTypeWithNsAndAssembly);
        //</snippet133>

        //<snippet140>
        // 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);
        //</snippet140>

        //<snippet150>
        // Get the name and the type of the field using its XML
        // element name and its XML namespace. For this query to work,
        // the containing type must be preloaded, and the XML element
        // name and the XML namespace must be explicitly declared on
        // the field using a SoapFieldAttribute.

        // Preload the containing type.
        SoapServices.PreLoad(typeof(ExampleNamespace.ExampleClass));

        // Get the name and the type of a field that will be
        // serialized as an XML element.
        Type   containingType      = typeof(ExampleNamespace.ExampleClass);
        string xmlElementNamespace =
            "http://example.org/ExampleFieldNamespace";
        string xmlElementName = "ExampleFieldElementName";
        Type   fieldType;
        string fieldName;

        SoapServices.GetInteropFieldTypeAndNameFromXmlElement(
            containingType, xmlElementName, xmlElementNamespace,
            out fieldType, out fieldName);
        Console.WriteLine(
            "The type of the field is {0}.",
            fieldType);
        Console.WriteLine(
            "The name of the field is {0}.",
            fieldName);

        // Get the name and the type of a field that will be
        // serialized as an XML attribute.
        string xmlAttributeNamespace =
            "http://example.org/ExampleAttributeNamespace";
        string xmlAttributeName = "ExampleFieldAttributeName";

        SoapServices.GetInteropFieldTypeAndNameFromXmlAttribute(
            containingType, xmlAttributeName, xmlAttributeNamespace,
            out fieldType, out fieldName);
        Console.WriteLine(
            "The type of the field is {0}.",
            fieldType);
        Console.WriteLine(
            "The name of the field is {0}.",
            fieldName);
        //</snippet150>

        //<snippet160>
        string interopTypeXmlElementName =
            "ExampleClassElementName";
        string interopTypeXmlNamespace =
            "http://example.org/ExampleXmlNamespace";
        Type interopType = SoapServices.GetInteropTypeFromXmlElement(
            interopTypeXmlElementName,
            interopTypeXmlNamespace);

        Console.WriteLine("The interop type is {0}.", interopType);

        string interopTypeXmlTypeName =
            "ExampleXmlTypeName";
        string interopTypeXmlTypeNamespace =
            "http://example.org/ExampleXmlTypeNamespace";

        interopType = SoapServices.GetInteropTypeFromXmlType(
            interopTypeXmlTypeName, interopTypeXmlTypeNamespace);
        Console.WriteLine("The interop type is {0}.", interopType);
        //</snippet160>

        //<snippet170>
        // Get the method base object for the GetHello method.
        System.Reflection.MethodBase methodBase =
            typeof(ExampleNamespace.ExampleClass).GetMethod("GetHello");

        // Print its current SOAP action.
        Console.WriteLine(
            "The SOAP action for the method " +
            "ExampleClass.GetHello is {0}.",
            SoapServices.GetSoapActionFromMethodBase(methodBase));

        // Set the SOAP action of the GetHello method to a new value.
        string newSoapAction =
            "http://example.org/ExampleSoapAction#NewSoapAction";

        SoapServices.RegisterSoapActionForMethodBase(
            methodBase, newSoapAction);
        Console.WriteLine(
            "The SOAP action for the method " +
            "ExampleClass.GetHello is {0}.",
            SoapServices.GetSoapActionFromMethodBase(methodBase));

        // Reset the SOAP action of the GetHello method to its default
        // value, which is determined using its SoapMethod attribute.
        SoapServices.RegisterSoapActionForMethodBase(methodBase);
        Console.WriteLine(
            "The SOAP action for the method " +
            "ExampleClass.GetHello is {0}.",
            SoapServices.GetSoapActionFromMethodBase(methodBase));
        //</snippet170>

        //<snippet120>
        // Register all types in the assembly with the SoapType attribute.
        System.Reflection.Assembly executingAssembly =
            System.Reflection.Assembly.GetExecutingAssembly();
        SoapServices.PreLoad(executingAssembly);
        //</snippet120>

        //<snippet121>
        // Register a specific type with the SoapType attribute.
        Type exampleType = typeof(ExampleNamespace.ExampleClass);

        SoapServices.PreLoad(exampleType);
        //</snippet121>

        //<snippet180>
        // Get the currently registered type for the given XML element
        // and namespace.
        string registeredXmlElementName =
            "ExampleClassElementName";
        string registeredXmlNamespace =
            "http://example.org/ExampleXmlNamespace";
        Type registeredType =
            SoapServices.GetInteropTypeFromXmlElement(
                registeredXmlElementName,
                registeredXmlNamespace);

        Console.WriteLine(
            "The registered interop type is {0}.",
            registeredType);

        // Register a new type for the XML element and namespace.
        SoapServices.RegisterInteropXmlElement(
            registeredXmlElementName,
            registeredXmlNamespace,
            typeof(String));

        // Get the currently registered type for the given XML element
        // and namespace.
        registeredType =
            SoapServices.GetInteropTypeFromXmlElement(
                registeredXmlElementName,
                registeredXmlNamespace);
        Console.WriteLine(
            "The registered interop type is {0}.",
            registeredType);
        //</snippet180>

        //<snippet190>
        // Get the currently registered type for the given XML element
        // and namespace.
        string registeredXmlTypeName =
            "ExampleXmlTypeName";
        string registeredXmlTypeNamespace =
            "http://example.org/ExampleXmlTypeNamespace";

        registeredType =
            SoapServices.GetInteropTypeFromXmlType(
                registeredXmlTypeName,
                registeredXmlTypeNamespace);
        Console.WriteLine(
            "The registered interop type is {0}.",
            registeredType);

        // Register a new type for the XML element and namespace.
        SoapServices.RegisterInteropXmlType(
            registeredXmlTypeName,
            registeredXmlTypeNamespace,
            typeof(String));

        // Get the currently registered type for the given XML element
        // and namespace.
        registeredType =
            SoapServices.GetInteropTypeFromXmlType(
                registeredXmlTypeName,
                registeredXmlTypeNamespace);
        Console.WriteLine(
            "The registered interop type is {0}.",
            registeredType);
        //</snippet190>
    }
 public virtual void GetObjectData(object obj, SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     if ((obj != null) && (obj != this._rootObj))
     {
         new MessageSurrogate(this._ss).GetObjectData(obj, info, context);
     }
     else
     {
         IMethodReturnMessage mm = obj as IMethodReturnMessage;
         if (mm != null)
         {
             if (mm.Exception != null)
             {
                 object data = CallContext.GetData("__ClientIsClr");
                 bool   flag = (data == null) || ((bool)data);
                 info.FullTypeName = "FormatterWrapper";
                 info.AssemblyName = this.DefaultFakeRecordAssemblyName;
                 Exception     innerException = mm.Exception;
                 StringBuilder builder        = new StringBuilder();
                 bool          flag2          = false;
                 while (innerException != null)
                 {
                     if (innerException.Message.StartsWith("MustUnderstand", StringComparison.Ordinal))
                     {
                         flag2 = true;
                     }
                     builder.Append(" **** ");
                     builder.Append(innerException.GetType().FullName);
                     builder.Append(" - ");
                     builder.Append(innerException.Message);
                     innerException = innerException.InnerException;
                 }
                 ServerFault serverFault = null;
                 if (flag)
                 {
                     serverFault = new ServerFault(mm.Exception);
                 }
                 else
                 {
                     serverFault = new ServerFault(mm.Exception.GetType().AssemblyQualifiedName, builder.ToString(), mm.Exception.StackTrace);
                 }
                 string faultCode = "Server";
                 if (flag2)
                 {
                     faultCode = "MustUnderstand";
                 }
                 SoapFault fault2 = new SoapFault(faultCode, builder.ToString(), null, serverFault);
                 info.AddValue("__WrappedObject", fault2, _soapFaultType);
             }
             else
             {
                 MethodBase          methodBase          = mm.MethodBase;
                 SoapMethodAttribute cachedSoapAttribute = (SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute(methodBase);
                 string    responseXmlElementName        = cachedSoapAttribute.ResponseXmlElementName;
                 string    responseXmlNamespace          = cachedSoapAttribute.ResponseXmlNamespace;
                 string    returnXmlElementName          = cachedSoapAttribute.ReturnXmlElementName;
                 ArgMapper mapper = new ArgMapper(mm, true);
                 object[]  args   = mapper.Args;
                 info.FullTypeName = responseXmlElementName;
                 info.AssemblyName = responseXmlNamespace;
                 Type returnType = ((MethodInfo)methodBase).ReturnType;
                 if ((returnType != null) && !(returnType == _voidType))
                 {
                     info.AddValue(returnXmlElementName, mm.ReturnValue, returnType);
                 }
                 if (args != null)
                 {
                     Type[] argTypes = mapper.ArgTypes;
                     for (int i = 0; i < args.Length; i++)
                     {
                         string argName = mapper.GetArgName(i);
                         if ((argName == null) || (argName.Length == 0))
                         {
                             argName = "__param" + i;
                         }
                         info.AddValue(argName, args[i], argTypes[i].IsByRef ? argTypes[i].GetElementType() : argTypes[i]);
                     }
                 }
             }
         }
         else
         {
             IMethodCallMessage m  = (IMethodCallMessage)obj;
             MethodBase         mb = m.MethodBase;
             string             xmlNamespaceForMethodCall = SoapServices.GetXmlNamespaceForMethodCall(mb);
             object[]           inArgs          = m.InArgs;
             string[]           inArgNames      = this.GetInArgNames(m, inArgs.Length);
             Type[]             methodSignature = (Type[])m.MethodSignature;
             info.FullTypeName = m.MethodName;
             info.AssemblyName = xmlNamespaceForMethodCall;
             int[] marshalRequestArgMap = InternalRemotingServices.GetReflectionCachedData(mb).MarshalRequestArgMap;
             for (int j = 0; j < inArgs.Length; j++)
             {
                 string name = null;
                 if ((inArgNames[j] == null) || (inArgNames[j].Length == 0))
                 {
                     name = "__param" + j;
                 }
                 else
                 {
                     name = inArgNames[j];
                 }
                 int  index = marshalRequestArgMap[j];
                 Type type  = null;
                 if (methodSignature[index].IsByRef)
                 {
                     type = methodSignature[index].GetElementType();
                 }
                 else
                 {
                     type = methodSignature[index];
                 }
                 info.AddValue(name, inArgs[j], type);
             }
         }
     }
 }
 public virtual void GetObjectData(object obj, SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     if (obj != null && obj != this._rootObj)
     {
         new MessageSurrogate(this._ss).GetObjectData(obj, info, context);
     }
     else
     {
         IMethodReturnMessage methodReturnMessage = obj as IMethodReturnMessage;
         if (methodReturnMessage != null)
         {
             if (methodReturnMessage.Exception == null)
             {
                 MethodBase          methodBase          = methodReturnMessage.MethodBase;
                 SoapMethodAttribute soapMethodAttribute = (SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute((object)methodBase);
                 string    responseXmlElementName        = soapMethodAttribute.ResponseXmlElementName;
                 string    responseXmlNamespace          = soapMethodAttribute.ResponseXmlNamespace;
                 string    returnXmlElementName          = soapMethodAttribute.ReturnXmlElementName;
                 ArgMapper argMapper = new ArgMapper((IMethodMessage)methodReturnMessage, true);
                 object[]  args      = argMapper.Args;
                 info.FullTypeName = responseXmlElementName;
                 info.AssemblyName = responseXmlNamespace;
                 Type returnType = ((MethodInfo)methodBase).ReturnType;
                 if (!(returnType == (Type)null) && !(returnType == SoapMessageSurrogate._voidType))
                 {
                     info.AddValue(returnXmlElementName, methodReturnMessage.ReturnValue, returnType);
                 }
                 if (args == null)
                 {
                     return;
                 }
                 Type[] argTypes = argMapper.ArgTypes;
                 for (int argNum = 0; argNum < args.Length; ++argNum)
                 {
                     string name = argMapper.GetArgName(argNum);
                     if (name == null || name.Length == 0)
                     {
                         name = "__param" + (object)argNum;
                     }
                     info.AddValue(name, args[argNum], argTypes[argNum].IsByRef ? argTypes[argNum].GetElementType() : argTypes[argNum]);
                 }
             }
             else
             {
                 object data  = CallContext.GetData("__ClientIsClr");
                 bool   flag1 = data == null || (bool)data;
                 info.FullTypeName = "FormatterWrapper";
                 info.AssemblyName = this.DefaultFakeRecordAssemblyName;
                 Exception     exception     = methodReturnMessage.Exception;
                 StringBuilder stringBuilder = new StringBuilder();
                 bool          flag2         = false;
                 for (; exception != null; exception = exception.InnerException)
                 {
                     if (exception.Message.StartsWith("MustUnderstand", StringComparison.Ordinal))
                     {
                         flag2 = true;
                     }
                     stringBuilder.Append(" **** ");
                     stringBuilder.Append(exception.GetType().FullName);
                     stringBuilder.Append(" - ");
                     stringBuilder.Append(exception.Message);
                 }
                 ServerFault serverFault = !flag1 ? new ServerFault(methodReturnMessage.Exception.GetType().AssemblyQualifiedName, stringBuilder.ToString(), methodReturnMessage.Exception.StackTrace) : new ServerFault(methodReturnMessage.Exception);
                 string      faultCode   = "Server";
                 if (flag2)
                 {
                     faultCode = "MustUnderstand";
                 }
                 SoapFault soapFault = new SoapFault(faultCode, stringBuilder.ToString(), (string)null, serverFault);
                 info.AddValue("__WrappedObject", (object)soapFault, SoapMessageSurrogate._soapFaultType);
             }
         }
         else
         {
             IMethodCallMessage m                      = (IMethodCallMessage)obj;
             MethodBase         methodBase             = m.MethodBase;
             string             namespaceForMethodCall = SoapServices.GetXmlNamespaceForMethodCall(methodBase);
             object[]           inArgs                 = m.InArgs;
             string[]           inArgNames             = this.GetInArgNames(m, inArgs.Length);
             Type[]             typeArray              = (Type[])m.MethodSignature;
             info.FullTypeName = m.MethodName;
             info.AssemblyName = namespaceForMethodCall;
             int[] marshalRequestArgMap = InternalRemotingServices.GetReflectionCachedData(methodBase).MarshalRequestArgMap;
             for (int index1 = 0; index1 < inArgs.Length; ++index1)
             {
                 string name   = inArgNames[index1] == null || inArgNames[index1].Length == 0 ? "__param" + (object)index1 : inArgNames[index1];
                 int    index2 = marshalRequestArgMap[index1];
                 Type   type   = !typeArray[index2].IsByRef ? typeArray[index2] : typeArray[index2].GetElementType();
                 info.AddValue(name, inArgs[index1], type);
             }
         }
     }
 }