CompleteCall() public abstract method

Completes reading the call A successful completion will have a single value: z
public abstract CompleteCall ( ) : void
return void
Ejemplo n.º 1
0
        /// <summary>
        /// Invoke the object with the request from the input stream.
        /// </summary>
        /// <param name="inHessian">the Hessian input stream</param>
        /// <param name="outHessian">the Hessian output stream</param>		
        public void invoke(AbstractHessianInput inHessian, AbstractHessianOutput outHessian)
        {
            inHessian.StartCall();
            MethodInfo methodInf = getMethodInfo(inHessian.Method);

            //If the method doesn't exist
            if (methodInf == null)
            {
                outHessian.StartReply();
                outHessian.WriteFault("NoSuchMethodException",
                    "The service has no method named: " + inHessian.Method,
                    null);
                outHessian.CompleteReply();
                return;
            }

            ParameterInfo[] paramInfo = methodInf.GetParameters();
            Object[] valuesParam = new Object[paramInfo.Length];

            for (int i = 0; i < paramInfo.Length; i++)
            {
                valuesParam[i] = inHessian.ReadObject(paramInfo[i].ParameterType);
            }
            inHessian.CompleteCall();

            Object result = null;

            try {
                result = methodInf.Invoke(m_Service,valuesParam);
            } catch(Exception e) {
                //TODO: Exception besser behandeln

                if (e.GetType() == typeof(System.Reflection.TargetInvocationException))
                {
                    if (e.InnerException != null)
                    {
                        e = e.InnerException;
                    }
                }
                outHessian.StartReply();
                outHessian.WriteFault("ServiceException", e.Message, e);

                outHessian.CompleteReply();
                return;
            }
            outHessian.StartReply();

            outHessian.WriteObject(result);

            outHessian.CompleteReply();
        }