Exemple #1
0
        private string ProcessJob(string message)
        {
            SoapMessage returnMessage = null;

            try
            {
                Log.Default.Trace("Create SoapCallMessage...");
                SoapCallMessage callMessage = SoapMessage.Deserialize <SoapCallMessage>(message);
                Log.Default.Trace("To:{0}", callMessage.To);
                string toRelative = callMessage.To;
                //toRelative = NetHelper.ToDnsAddress(toRelative);
                toRelative = new Uri(toRelative).AbsolutePath;
                toRelative = toRelative.Substring(m_proxyServer.AbsolutePath.Length);
                toRelative = "/" + toRelative.Replace(m_proxyServer.ToString(), String.Empty);
                Log.Default.Trace("toRelative:{0}", toRelative);
                SoapCallProxy callProxy = m_jobProxy.GetProxy(toRelative);
                if (callProxy != null)
                {
                    Log.Default.Trace("find job handler");
                    return(callProxy.Execute(message));
                }
                else
                {
                    Log.Default.Error("Invalid job!");
                    returnMessage = new SoapFaultMessage(SoapCode.Client, "Not implement!");
                }
            }
            catch (Exception ex)
            {
                Log.Default.Error("TODO: every exception here must be fixed!");
                Log.Default.LogException(ex);
                returnMessage = new SoapFaultMessage(SoapCode.Server, "Framework error, should be fixed!\r\n" + ex.GetExceptionText());
            }
            return(SoapMessage.Serialize(returnMessage));
        }
Exemple #2
0
        public virtual string Execute(string message)
        {
            Log.Default.Trace("Execute.");
            SoapMessage     returnMessage = null;
            SoapCallMessage soapMessage   = SoapMessage.Deserialize <SoapCallMessage>(message);

            try
            {
                string action = soapMessage.Action;
                Log.Default.Trace(string.Format("Action:{0}", action));
                MethodInfo method = null;
                if (!m_actions.TryGetValue(action, out method))
                {
                    string errMsg = string.Format("The action {0}  doesn't exists!", action);
                    throw new InvalidOperationException(errMsg);
                }
                Log.Default.Trace("Create Name:{0}", method.Name);
                object[] args = soapMessage.GetInArgs(method);
                Log.Default.Trace("Invoke method:{0}", method.Name);
                object result = method.Invoke(m_instance, args);
                //Log.Default.Trace("result:{0}", result);
                Log.Default.Trace("Invoke method:{0} done", method.Name);
                Dictionary <string, object> outArgs = GetOutArgs(method, args);
                returnMessage = new SoapReturnMessage(method, result, outArgs);
            }
            catch (Exception ex)
            {
                Log.Default.LogException(ex);
                returnMessage = new SoapFaultMessage(SoapCode.Server, "Error:" + ex.Message + "\n\rText:" + ex.GetExceptionText());
            }
            string response = SoapMessage.Serialize(returnMessage);

            return(response);
        }