Exemplo n.º 1
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();
            }
        }
Exemplo n.º 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();
            //BufferedStream bs = new BufferedStream(m_stream);

            var serviceUrl = string.Empty;

            //Reads the Header of HTTP Message
            try
            {
                serviceUrl = ReadHeaders();
            }
            catch (NotSupportedException e)
            {
                SendError(500, "Close");
                m_socket.Shutdown(SocketShutdown.Both);
                m_socket.Close();
                m_stream.Close();
                return;
            }
            AbstractHessianInput  inHessian      = new CHessianInput(m_stream);
            AbstractHessianOutput tempOutHessian = new CHessianOutput(memoryStream);

            /// Proxy object
            CHessianSkeleton objectSkeleton = null;

            try
            {
                var m_Service = ServiceFactory.SelectService(serviceUrl);
                if (m_Service == null)
                {
                    throw new NotSupportedException("This ServiceUrl is not supported");
                }
                objectSkeleton = new CHessianSkeleton(m_Service.GetType(), m_Service);
                //SendOk(bs, 0);
                objectSkeleton.invoke(inHessian, tempOutHessian);
                WriteResponse(memoryStream.ToArray());
            }
            catch (Exception e)
            {
                SendError(500, e.GetBaseException().Message);
            }
            finally
            {
                m_socket.Shutdown(SocketShutdown.Both);
                m_socket.Close();
                m_stream.Close();
            }
        }
Exemplo n.º 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;
            }
        }