Ejemplo n.º 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.GetBaseException().Message;
            }
        }
Ejemplo n.º 2
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(ctx.Response.OutputStream);

                var service = ServiceFactory.SelectService(ctx.Request.Path);
                if (service == null)
                {
                    ctx.Response.StatusCode        = 404; // "Internal server error"
                    ctx.Response.StatusDescription = "Service Not Found.";
                    return;
                }
                //Vieleicht das Interface als API übergeben???
                var m_objectSkeleton = new CHessianSkeleton(service.GetType(), service);

                m_objectSkeleton.invoke(inStream, ctx.Response.OutputStream);
                //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"
                var encode = System.Web.HttpUtility.UrlEncode(ex.Message);
                ctx.Response.StatusDescription = encode.Length > 512 ? encode.Substring(0, 512) : encode;
            }
        }