Пример #1
0
        /// <summary>
        /// Execute a request.
        /// </summary>
        public void ProcessRequest(HttpContext ctx)
        {
            try
            {
                context = ctx;
                Stream       inStream  = ctx.Request.InputStream;
                MemoryStream outStream = new MemoryStream();

                ctx.Response.BufferOutput = true;
                ctx.Response.ContentType  = "text/xml";

                AbstractHessianInput  inHessian  = new CHessianInput(inStream);
                AbstractHessianOutput outHessian = new CHessianOutput(outStream);

                if (m_objectSkeleton == null)
                {
                    //Vieleicht das Interface als API übergeben???
                    m_objectSkeleton = new CHessianSkeleton(this.GetType(), this);
                }

                m_objectSkeleton.invoke(inHessian, outHessian);
                byte [] arrData   = outStream.ToArray();
                int     intLength = arrData.Length;
                //Set length
                ctx.Response.AppendHeader("Content-Length", intLength.ToString());
                //Write stream
                ctx.Response.OutputStream.Write(arrData, 0, intLength);
                return;
            }
            catch (Exception ex)
            {
                ctx.Response.StatusCode        = 500; // "Internal server error"
                ctx.Response.StatusDescription = ex.Message;
            }
        }
Пример #2
0
        /// <summary>
        /// The Request will be processed here.
        /// The main function in this class
        /// </summary>
        public void ProcessRequest()
        {
            //Get references to sockets input & output streams
            m_stream = new NetworkStream(m_socket, FileAccess.ReadWrite, true);
            MemoryStream memoryStream = new MemoryStream();
            //Reads the Header of HTTP Message
            try {
                ReadHeaders();
            } catch (NotSupportedException e) {
                SendError(500, "Close");
                m_socket.Close();
                m_stream.Close();
                return;
            }
            AbstractHessianInput inHessian = new CHessianInput(m_stream);
            AbstractHessianOutput tempOutHessian = new CHessianOutput(memoryStream);

            /// Proxy object
            CHessianSkeleton objectSkeleton = null;
            try {
                objectSkeleton = new CHessianSkeleton(m_apiType, m_Service);
                objectSkeleton.invoke(inHessian, tempOutHessian);
                WriteResponse(memoryStream.ToArray());
            } catch (Exception e) {
                SendError(500, "Close");
            } finally {
                m_socket.Close();
                m_stream.Close();
            }
        }
Пример #3
0
        protected override void ProcessRequest(System.Net.HttpListenerContext ctx)
        {
            try
            {
                context = ctx;
                Stream inStream = ctx.Request.InputStream;
                MemoryStream outStream = new MemoryStream();

                //ctx.Response.BufferOutput = true;
                ctx.Response.ContentType = "text/xml";

                AbstractHessianInput inHessian = new CHessianInput(inStream);
                AbstractHessianOutput outHessian = new CHessianOutput(outStream);

                if (m_objectSkeleton == null)
                {
                    //Vieleicht das Interface als API übergeben???
                    m_objectSkeleton = new CHessianSkeleton(this.GetType(), this);
                }

                m_objectSkeleton.invoke(inHessian, outHessian);
                byte[] arrData = outStream.ToArray();
                int intLength = arrData.Length;
                //Set length
                ctx.Response.ContentLength64 = intLength;

                //Write stream
                ctx.Response.OutputStream.Write(arrData, 0, intLength);
                return;
            }
            catch (Exception ex)
            {
                ctx.Response.StatusCode = 500;  // "Internal server error"
                ctx.Response.StatusDescription = ex.Message;
            }
        }