Beispiel #1
0
        } // ReplaceMachineNameWithIpAddress

        internal static String ReplaceChannelUriWithThisString(String url, String channelUri)
        {
            // NOTE: channelUri is assumed to be scheme://machinename:port
            //   with NO trailing slash.

            String oldChannelUri;
            String objUri;

            oldChannelUri = HttpChannelHelper.ParseURL(url, out objUri);
            InternalRemotingServices.RemotingAssert(oldChannelUri != null, "http url expected.");
            InternalRemotingServices.RemotingAssert(objUri != null, "non-null objUri expected.");

            return(channelUri + objUri);
        } // ReplaceChannelUriWithThisString
Beispiel #2
0
        } // WriteInt32

        protected bool ReadAndMatchFourBytes(byte[] buffer)
        {
            InternalRemotingServices.RemotingAssert(buffer.Length == 4, "expecting 4 byte buffer.");

            Read(_byteBuffer, 0, 4);

            bool bMatch =
                (_byteBuffer[0] == buffer[0]) &&
                (_byteBuffer[1] == buffer[1]) &&
                (_byteBuffer[2] == buffer[2]) &&
                (_byteBuffer[3] == buffer[3]);

            return(bMatch);
        } // ReadAndMatchFourBytes
Beispiel #3
0
        void ProcessResponse(ISmtpMessage smtpMessage, String contentType,
                             String seqNum, MemoryStream stm)
        {
            InternalRemotingServices.RemotingTrace("Received response");

            // Notify the waiting object that its response
            // has arrived
            WaitObject obj = (WaitObject)m_hashTable[seqNum];

            if (null != obj)
            {
                InternalRemotingServices.RemotingTrace("Found an object waiting");

                // First remove the object in a threadsafe manner
                // so that we do not deliver the response twice
                // due to duplicate replies or other errors from
                // Smtp

                lock (obj)
                {
                    if (m_hashTable.Contains(seqNum))
                    {
                        InternalRemotingServices.RemotingTrace("Found an object to notify");
                        m_hashTable.Remove(seqNum);

                        IMethodCallMessage request = (IMethodCallMessage)obj.Request;
                        Header[]           h       = new Header[3];
                        h[0] = new Header("__TypeName", request.TypeName);
                        h[1] = new Header("__MethodName", request.MethodName);
                        h[2] = new Header("__MethodSignature", request.MethodSignature);

                        IMessage response = CoreChannel.DeserializeMessage(contentType, stm, false, request, h);
                        InternalRemotingServices.RemotingTrace("Deserialized message");

                        if (response == null)
                        {
                            throw new Exception(CoreChannel.GetResourceString("Remoting_DeserializeMessage"));
                        }

                        // Notify the object
                        obj.Notify(response);
                    }
                }
            }
            else
            {
                InternalRemotingServices.RemotingTrace("No object waiting");
            }
        }
Beispiel #4
0
        } // StartListening

        /// <include file='doc\HttpServerChannel.uex' path='docs/doc[@for="HttpServerChannel.StopListening"]/*' />
        public void StopListening(Object data)
        {
            InternalRemotingServices.RemotingTrace("HTTPChannel.StopListening");

            if (_port > 0)
            {
                _bListening = false;

                // Ask the TCP listener to stop listening on the port
                if (null != _tcpListener)
                {
                    _tcpListener.Stop();
                }
            }
        } // StopListening
Beispiel #5
0
        public string GetArgName(int index)
        {
            if (index >= this.ArgCount)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(this.GetMethodBase());

            ParameterInfo[] parameters = reflectionCachedData.Parameters;
            if (index < parameters.Length)
            {
                return(parameters[index].Name);
            }
            return("VarArg" + (index - parameters.Length));
        }
        internal ArgMapper(IMethodMessage mm, bool fOut)
        {
            this._mm = mm;
            MethodBase methodBase = this._mm.MethodBase;

            this._methodCachedData = InternalRemotingServices.GetReflectionCachedData(methodBase);
            if (fOut)
            {
                this._map = this._methodCachedData.MarshalResponseArgMap;
            }
            else
            {
                this._map = this._methodCachedData.MarshalRequestArgMap;
            }
        }
Beispiel #7
0
        public string GetArgName(int index)
        {
            if (this.MI == null)
            {
                return("__param" + index);
            }
            RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(this.MI);

            ParameterInfo[] parameters = reflectionCachedData.Parameters;
            if ((index < 0) || (index >= parameters.Length))
            {
                throw new ArgumentOutOfRangeException("index");
            }
            return(reflectionCachedData.Parameters[index].Name);
        }
Beispiel #8
0
        /// <include file='doc\ChannelSinkStacks.uex' path='docs/doc[@for="ServerChannelSinkStack.ServerCallback"]/*' />
        public void ServerCallback(IAsyncResult ar)
        {
            if (_asyncEnd != null)
            {
                RemotingMethodCachedData asyncEndCache = (RemotingMethodCachedData)
                                                         InternalRemotingServices.GetReflectionCachedData(_asyncEnd);

                MethodInfo syncMI = (MethodInfo)_msg.MethodBase;
                RemotingMethodCachedData syncCache = (RemotingMethodCachedData)
                                                     InternalRemotingServices.GetReflectionCachedData(syncMI);

                ParameterInfo[] paramList = asyncEndCache.Parameters;

                // construct list to pass into End
                Object[] parameters = new Object[paramList.Length];
                parameters[paramList.Length - 1] = ar; // last parameter is the async result

                Object[] syncMsgArgs = _msg.Args;

                // copy out and ref parameters to the parameters list
                AsyncMessageHelper.GetOutArgs(syncCache.Parameters, syncMsgArgs, parameters);

                Object[] outArgs;

                StackBuilderSink s           = new StackBuilderSink(_serverObject);
                Object           returnValue =
                    s.PrivateProcessMessage(_asyncEnd,
                                            System.Runtime.Remoting.Messaging.Message.CoerceArgs(_asyncEnd, parameters, paramList),
                                            _serverObject,
                                            0,
                                            false,
                                            out outArgs);

                // The outArgs list is associated with the EndXXX method. We need to make sure
                //   it is sized properly for the out args of the XXX method.
                if (outArgs != null)
                {
                    outArgs = ArgMapper.ExpandAsyncEndArgsToSyncArgs(syncCache, outArgs);
                }

                s.CopyNonByrefOutArgsFromOriginalArgs(syncCache, syncMsgArgs, ref outArgs);

                IMessage retMessage = new ReturnMessage(
                    returnValue, outArgs, _msg.ArgCount, CallContext.GetLogicalCallContext(), _msg);

                AsyncProcessResponse(retMessage, null, null);
            }
        } // ServerCallback
Beispiel #9
0
        private void SerializeSimpleObject(
            object currentObject,
            long currentObjectId)
        {
            Type currentType = currentObject.GetType();

            // Value type have to be serialized "on the fly" so
            // SerializeComponent calls SerializeObject when
            // a field of another object is a struct. A node with the field
            // name has already be written so WriteStartElement must not be called
            // again. Fields that are structs are passed to SerializeObject
            // with a id = 0
            if (currentObjectId > 0)
            {
                Element element = _mapper.GetXmlElement(currentType);
                _xmlWriter.WriteStartElement(element.Prefix, element.LocalName, element.NamespaceURI);
                Id(currentObjectId);
            }

            if (currentType == typeof(TimeSpan))
            {
                _xmlWriter.WriteString(SoapTypeMapper.GetXsdValue(currentObject));
            }
            else if (currentType == typeof(string))
            {
                _xmlWriter.WriteString(currentObject.ToString());
            }
            else
            {
                MemberInfo[] memberInfos = FormatterServices.GetSerializableMembers(currentType, _context);
                object[]     objectData  = FormatterServices.GetObjectData(currentObject, memberInfos);

                for (int i = 0; i < memberInfos.Length; i++)
                {
                    FieldInfo          fieldInfo = (FieldInfo)memberInfos[i];
                    SoapFieldAttribute at        = (SoapFieldAttribute)InternalRemotingServices.GetCachedSoapAttribute(fieldInfo);
                    _xmlWriter.WriteStartElement(XmlConvert.EncodeLocalName(at.XmlElementName));
                    SerializeComponent(
                        objectData[i],
                        IsEncodingNeeded(objectData[i], fieldInfo.FieldType));
                    _xmlWriter.WriteEndElement();
                }
            }
            if (currentObjectId > 0)
            {
                _xmlWriter.WriteFullEndElement();
            }
        }
        } // TcpClientTransportSink

        public void ProcessMessage(IMessage msg,
                                   ITransportHeaders requestHeaders, Stream requestStream,
                                   out ITransportHeaders responseHeaders, out Stream responseStream)
        {
            InternalRemotingServices.RemotingTrace("TcpClientTransportSink::ProcessMessage");

            TcpClientSocketHandler clientSocket =
                SendRequestWithRetry(msg, requestHeaders, requestStream);

            // receive response
            responseHeaders = clientSocket.ReadHeaders();
            responseStream  = clientSocket.GetResponseStream();

            // The client socket will be returned to the cache
            //   when the response stream is closed.
        } // ProcessMessage
Beispiel #11
0
        internal static void DebugException(String name, Exception e)
        {
            InternalRemotingServices.RemotingTrace("****************************************************\r\n");
            InternalRemotingServices.RemotingTrace("EXCEPTION THROWN!!!!!! - " + name);
            InternalRemotingServices.RemotingTrace("\r\n");

            InternalRemotingServices.RemotingTrace(e.Message);
            InternalRemotingServices.RemotingTrace("\r\n");

            InternalRemotingServices.RemotingTrace(e.GetType().FullName);
            InternalRemotingServices.RemotingTrace("\r\n");

            InternalRemotingServices.RemotingTrace(e.StackTrace);
            InternalRemotingServices.RemotingTrace("\r\n");
            InternalRemotingServices.RemotingTrace("****************************************************\r\n");
        }
Beispiel #12
0
        } // OnNetworkAddressChanged

        private static void UpdateCachedIPAddresses()
        {
            try
            {
                s_CachedIPHostEntry = Dns.GetHostEntry(GetMachineName());
            }
            catch (Exception exception)
            {
                s_CachedIPHostEntry = null;

                InternalRemotingServices.RemotingTrace(string.Format(
                                                           "CoreChannel.UpdateCachedIPAddresses caught exception '{0}'; \r\nMessage: {1}", exception.GetType().ToString(), exception.Message));

                throw;
            }
        } // UpdateCachedIPAddresses
Beispiel #13
0
        internal static IRemotingFormatter MimeTypeToFormatter(String mimeType, bool serialize)
        {
            InternalRemotingServices.RemotingTrace("MimeTypeToFormatter: mimeType: " + mimeType);

            if (string.Compare(mimeType, SOAPMimeType, false, CultureInfo.InvariantCulture) == 0)
            {
                return(CreateSoapFormatter(serialize, true));
            }
            else
            if (string.Compare(mimeType, BinaryMimeType, false, CultureInfo.InvariantCulture) == 0)
            {
                return(CreateBinaryFormatter(serialize, true));
            }

            return(null);
        } // MimeTypeToFormatter
Beispiel #14
0
        } // ReleaseSocket

        private SocketHandler CreateNewSocket()
        {
            Socket socket = new Socket(AddressFamily.InterNetwork,
                                       SocketType.Stream,
                                       ProtocolType.Tcp);

            // disable nagle delays
            socket.SetSocketOption(SocketOptionLevel.Tcp,
                                   SocketOptionName.NoDelay,
                                   1);

            InternalRemotingServices.RemotingTrace("RemoteConnection::CreateNewSocket: connecting new socket :: " + _ipEndPoint);

            socket.Connect(_ipEndPoint);

            return(_socketCache.CreateSocketHandler(socket, _machineAndPort));
        } // CreateNewSocket
Beispiel #15
0
        void WriteException(HttpContext context, Exception e)
        {
            InternalRemotingServices.RemotingTrace("HttpHandler: Exception thrown...\n");
            InternalRemotingServices.RemotingTrace(e.StackTrace);

            Stream outputStream = context.Response.OutputStream;

            context.Response.Clear();
            context.Response.ClearHeaders();
            context.Response.ContentType       = ComposeContentType("text/plain", Encoding.UTF8);
            context.Response.StatusCode        = (int)HttpStatusCode.InternalServerError;
            context.Response.StatusDescription = CoreChannel.GetResourceString("Remoting_InternalError");
            StreamWriter writer = new StreamWriter(outputStream, new UTF8Encoding(false));

            writer.WriteLine(GenerateFaultString(context, e));
            writer.Flush();
        }
Beispiel #16
0
        public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg)
        {
            if (ctorMsg == null)
            {
                throw new ArgumentNullException("ctorMsg");
            }
            if (ctorMsg.Properties.Contains((object)"Remote"))
            {
                return(LocalActivator.DoRemoteActivation(ctorMsg));
            }
            if (!ctorMsg.Properties.Contains((object)"Permission"))
            {
                return(ctorMsg.Activator.Activate(ctorMsg));
            }
            Type activationType = ctorMsg.ActivationType;

            object[] activationAttributes = (object[])null;
            if (activationType.IsContextful)
            {
                IList contextProperties = ctorMsg.ContextProperties;
                if (contextProperties != null && contextProperties.Count > 0)
                {
                    activationAttributes = new object[1]
                    {
                        (object)new RemotePropertyHolderAttribute(contextProperties)
                    }
                }
                ;
            }
            RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(LocalActivator.GetMethodBase(ctorMsg));

            object[] args      = Message.CoerceArgs((IMethodMessage)ctorMsg, reflectionCachedData.Parameters);
            object   serverObj = Activator.CreateInstance(activationType, args, activationAttributes);

            if (RemotingServices.IsClientProxy(serverObj))
            {
                RedirectionProxy redirectionProxy = new RedirectionProxy((MarshalByRefObject)serverObj, activationType);
                // ISSUE: variable of the null type
                __Null local         = null;
                Type   RequestedType = activationType;
                RemotingServices.MarshalInternal((MarshalByRefObject)redirectionProxy, (string)local, RequestedType);
                serverObj = (object)redirectionProxy;
            }
            return(ActivationServices.SetupConstructionReply(serverObj, ctorMsg, (Exception)null));
        }
Beispiel #17
0
        public void StartListening(Object data)
        {
            InternalRemotingServices.RemotingTrace("IpcChannel.StartListening");

            if (_listenerThread.IsAlive == false)
            {
                _listenerThread.Start();
                _waitForStartListening.WaitOne(); // listener thread will signal this after starting IpcListener

                if (_startListeningException != null)
                {
                    // An exception happened when we tried to start listening (such as "socket already in use)
                    Exception e = _startListeningException;
                    _startListeningException = null;
                    throw e;
                }
            }
        } // StartListening
Beispiel #18
0
        public MethodResponse(Header[] h1, IMethodCallMessage mcm)
        {
            if (mcm == null)
            {
                throw new ArgumentNullException("mcm");
            }
            Message message = mcm as Message;

            this.MI = message == null ? mcm.MethodBase : message.GetMethodBase();
            if (this.MI == (MethodBase)null)
            {
                throw new RemotingException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Message_MethodMissing"), (object)mcm.MethodName, (object)mcm.TypeName));
            }
            this._methodCache = InternalRemotingServices.GetReflectionCachedData(this.MI);
            this.argCount     = this._methodCache.Parameters.Length;
            this.fSoap        = true;
            this.FillHeaders(h1);
        }
Beispiel #19
0
        string GetXmlNamespace(Type t, Type containerType)
        {
            string name, ns;

            if (t.IsArray)
            {
                return(GetXmlNamespace(containerType, null));
            }

            if (SoapServices.GetXmlTypeForInteropType(t, out name, out ns))
            {
                return(ns);
            }

            SoapTypeAttribute att = (SoapTypeAttribute)InternalRemotingServices.GetCachedSoapAttribute(t);

            return(att.XmlNamespace);
        }
Beispiel #20
0
 public string GetArgName(int index)
 {
     if (this._outArgs == null)
     {
         if ((index < 0) || (index >= this._outArgsCount))
         {
             throw new ArgumentOutOfRangeException("index");
         }
     }
     else if ((index < 0) || (index >= this._outArgs.Length))
     {
         throw new ArgumentOutOfRangeException("index");
     }
     if (this._methodBase != null)
     {
         return(InternalRemotingServices.GetReflectionCachedData(this._methodBase).Parameters[index].Name);
     }
     return("__param" + index);
 }
Beispiel #21
0
        } // SerializeMessage

        internal static void SerializeMessage(String mimeType, IMessage msg, Stream outputStream,
                                              bool includeVersions)
        {
            InternalRemotingServices.RemotingTrace("SerializeMessage");
            InternalRemotingServices.RemotingTrace("MimeType: " + mimeType);
            CoreChannel.DebugMessage(msg);

            if (string.Compare(mimeType, SOAPMimeType, false, CultureInfo.InvariantCulture) == 0)
            {
                SerializeSoapMessage(msg, outputStream, includeVersions);
            }
            else
            if (string.Compare(mimeType, BinaryMimeType, false, CultureInfo.InvariantCulture) == 0)
            {
                SerializeBinaryMessage(msg, outputStream, includeVersions);
            }

            InternalRemotingServices.RemotingTrace("SerializeMessage: OUT");
        } // SerializeMessage
Beispiel #22
0
        public static void PreLoad(Type type)
        {
            foreach (MethodBase method in type.GetMethods())
            {
                SoapServices.RegisterSoapActionForMethodBase(method);
            }
            SoapTypeAttribute cachedSoapAttribute1 = (SoapTypeAttribute)InternalRemotingServices.GetCachedSoapAttribute((object)type);

            if (cachedSoapAttribute1.IsInteropXmlElement())
            {
                SoapServices.RegisterInteropXmlElement(cachedSoapAttribute1.XmlElementName, cachedSoapAttribute1.XmlNamespace, type);
            }
            if (cachedSoapAttribute1.IsInteropXmlType())
            {
                SoapServices.RegisterInteropXmlType(cachedSoapAttribute1.XmlTypeName, cachedSoapAttribute1.XmlTypeNamespace, type);
            }
            int num = 0;

            SoapServices.XmlToFieldTypeMap xmlToFieldTypeMap = new SoapServices.XmlToFieldTypeMap();
            foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
            {
                SoapFieldAttribute cachedSoapAttribute2 = (SoapFieldAttribute)InternalRemotingServices.GetCachedSoapAttribute((object)field);
                if (cachedSoapAttribute2.IsInteropXmlElement())
                {
                    string xmlElementName = cachedSoapAttribute2.XmlElementName;
                    string xmlNamespace   = cachedSoapAttribute2.XmlNamespace;
                    if (cachedSoapAttribute2.UseAttribute)
                    {
                        xmlToFieldTypeMap.AddXmlAttribute(field.FieldType, field.Name, xmlElementName, xmlNamespace);
                    }
                    else
                    {
                        xmlToFieldTypeMap.AddXmlElement(field.FieldType, field.Name, xmlElementName, xmlNamespace);
                    }
                    ++num;
                }
            }
            if (num <= 0)
            {
                return;
            }
            SoapServices._xmlToFieldTypeMap[(object)type] = (object)xmlToFieldTypeMap;
        }
Beispiel #23
0
        void SendMessage(IMessage msg, String receiver, String seqNum)
        {
            if (msg == null)
            {
                throw new ArgumentNullException("msg");
            }

            InternalRemotingServices.RemotingTrace("SmtpMessageSink::ProcessAndSend 1");

            //
            // Serialize the message
            //
            byte [] byteMessage;
            int     byteMessageLength = 0;

            InternalRemotingServices.RemotingTrace("SmtpMessageSink::ProcessAndSend 2");

            MemoryStream stm = (MemoryStream)CoreChannel.SerializeMessage(m_mimeType, msg);

            InternalRemotingServices.RemotingTrace("SmtpMessageSink::ProcessAndSend 3");
            // reset stream to beginning
            stm.Position      = 0;
            byteMessage       = stm.ToArray();
            byteMessageLength = byteMessage.Length;

            //
            // Create a new mail message
            //
            MailMessage mail = new MailMessage();

            // Add the required and optional headers
            PutHeaders(mail, (IMethodCallMessage)msg, receiver, seqNum, byteMessageLength);

            // Add the body of the message
            mail.Body = System.Text.Encoding.ASCII.GetString(byteMessage, 0, byteMessage.Length);

            //
            // Send request
            //
            InternalRemotingServices.RemotingTrace("SmtpMessageSink::ProcessAndSend before Send");
            SmtpMail.Send(mail);
        }
        } // TcpClientTransportSink

        public void ProcessMessage(IMessage msg,
                                   ITransportHeaders requestHeaders, Stream requestStream,
                                   out ITransportHeaders responseHeaders, out Stream responseStream)
        {
            InternalRemotingServices.RemotingTrace("TcpClientTransportSink::ProcessMessage");

            // the call to SendRequest can block a func eval, so we want to notify the debugger that we're
            // about to call a blocking operation.
            System.Diagnostics.Debugger.NotifyOfCrossThreadDependency();

            TcpClientSocketHandler clientSocket =
                SendRequestWithRetry(msg, requestHeaders, requestStream);

            // receive response
            responseHeaders = clientSocket.ReadHeaders();
            responseStream  = clientSocket.GetResponseStream();

            // The client socket will be returned to the cache
            //   when the response stream is closed.
        } // ProcessMessage
        } // ProcessMessage

        public void AsyncProcessRequest(IClientChannelSinkStack sinkStack, IMessage msg,
                                        ITransportHeaders headers, Stream stream)
        {
            InternalRemotingServices.RemotingTrace("TcpClientTransportSink::AsyncProcessRequest");

            TcpClientSocketHandler clientSocket =
                SendRequestWithRetry(msg, headers, stream);

            if (clientSocket.OneWayRequest)
            {
                clientSocket.ReturnToCache();
            }
            else
            {
                // do an async read on the reply
                clientSocket.DataArrivedCallback      = new WaitCallback(this.ReceiveCallback);
                clientSocket.DataArrivedCallbackState = sinkStack;
                clientSocket.BeginReadMessage();
            }
        } // AsyncProcessRequest
Beispiel #26
0
        internal static void SerializeSoapMessage(IMessage msg, Stream outputStream, bool includeVersions)
        {
            SoapFormatter  formatter = CreateSoapFormatter(true, includeVersions);
            IMethodMessage message   = msg as IMethodMessage;

            if ((message != null) && (message.MethodBase != null))
            {
                SoapTypeAttribute cachedSoapAttribute = (SoapTypeAttribute)InternalRemotingServices.GetCachedSoapAttribute(message.MethodBase.DeclaringType);
                if ((cachedSoapAttribute.SoapOptions & SoapOption.AlwaysIncludeTypes) == SoapOption.AlwaysIncludeTypes)
                {
                    formatter.TypeFormat |= FormatterTypeStyle.TypesAlways;
                }
                if ((cachedSoapAttribute.SoapOptions & SoapOption.XsdString) == SoapOption.XsdString)
                {
                    formatter.TypeFormat |= FormatterTypeStyle.XsdString;
                }
            }
            Header[] soapHeaders = GetSoapHeaders(msg);
            ((RemotingSurrogateSelector)formatter.SurrogateSelector).SetRootObject(msg);
            formatter.Serialize(outputStream, msg, soapHeaders);
        }
        public void StartListening(Object data)
        {
            InternalRemotingServices.RemotingTrace("HTTPChannel.StartListening");

            if (_port >= 0)
            {
                _tcpListener.Start(_bExclusiveAddressUse);
                _bListening = true;
                // get new port assignment if a port of 0 was used to auto-select a port
                if (_port == 0)
                {
                    _port = ((IPEndPoint)_tcpListener.LocalEndpoint).Port;
                    if (_channelData != null)
                    {
                        _channelData.ChannelUris    = new String[1];
                        _channelData.ChannelUris[0] = GetChannelUri();
                    }
                }
                _tcpListener.BeginAcceptSocket(_acceptSocketCallback, null);
            }
        } // StartListening
Beispiel #28
0
 public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg)
 {
     if (ctorMsg == null)
     {
         throw new ArgumentNullException("ctorMsg");
     }
     if (ctorMsg.Properties.Contains("Remote"))
     {
         return(LocalActivator.DoRemoteActivation(ctorMsg));
     }
     if (ctorMsg.Properties.Contains("Permission"))
     {
         Type     activationType       = ctorMsg.ActivationType;
         object[] activationAttributes = null;
         if (activationType.IsContextful)
         {
             IList contextProperties = ctorMsg.ContextProperties;
             if (contextProperties != null && contextProperties.Count > 0)
             {
                 RemotePropertyHolderAttribute remotePropertyHolderAttribute = new RemotePropertyHolderAttribute(contextProperties);
                 activationAttributes = new object[]
                 {
                     remotePropertyHolderAttribute
                 };
             }
         }
         MethodBase methodBase = LocalActivator.GetMethodBase(ctorMsg);
         RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(methodBase);
         object[] args = Message.CoerceArgs(ctorMsg, reflectionCachedData.Parameters);
         object   obj  = Activator.CreateInstance(activationType, args, activationAttributes);
         if (RemotingServices.IsClientProxy(obj))
         {
             RedirectionProxy redirectionProxy = new RedirectionProxy((MarshalByRefObject)obj, activationType);
             RemotingServices.MarshalInternal(redirectionProxy, null, activationType);
             obj = redirectionProxy;
         }
         return(ActivationServices.SetupConstructionReply(obj, ctorMsg, null));
     }
     return(ctorMsg.Activator.Activate(ctorMsg));
 }
Beispiel #29
0
        } // HttpClientTransportSink

        public void ProcessMessage(IMessage msg,
                                   ITransportHeaders requestHeaders, Stream requestStream,
                                   out ITransportHeaders responseHeaders, out Stream responseStream)
        {
            InternalRemotingServices.RemotingTrace("HttpTransportSenderSink::ProcessMessage");

            HttpWebRequest httpWebRequest = ProcessAndSend(msg, requestHeaders, requestStream);

            // receive server response
            HttpWebResponse response = null;

            try
            {
                response = (HttpWebResponse)httpWebRequest.GetResponse();
            }
            catch (WebException webException)
            {
                ProcessResponseException(webException, out response);
            }

            ReceiveAndProcess(response, out responseHeaders, out responseStream);
        } // ProcessMessage
        void DumpRequest(HttpContext context)
        {
            HttpRequest request = context.Request;

            InternalRemotingServices.DebugOutChnl("Process Request called.");
            InternalRemotingServices.DebugOutChnl("Path = " + request.Path);
            InternalRemotingServices.DebugOutChnl("PhysicalPath = " + request.PhysicalPath);
            //InternalRemotingServices.DebugOutChnl("QueryString = " + request.Url.QueryString);
            InternalRemotingServices.DebugOutChnl("HttpMethod = " + request.HttpMethod);
            InternalRemotingServices.DebugOutChnl("ContentType = " + request.ContentType);
            InternalRemotingServices.DebugOutChnl("PathInfo = " + request.PathInfo);

            /*
             * String[] keys = request.Headers.AllKeys;
             * String[] values = request.Headers.All;
             *
             * for (int i=0; i<keys.Length; i++)
             * {
             *  InternalRemotingServices.DebugOutChnl("Header :: " + keys[i] + "/" + values[i]);
             * }
             */
        }