//[HttpPost]
        public async Task <ActionResult> BatchInvoke()
        {
            if (!Enabled)
            {
                return(this.JsonResult(-1, "ApiProxy is not enabled."));
            }

            InvokeContext context;

            if (HttpContext.Request.HttpMethod == "GET")
            {
                context = new InvokeContext()
                {
                    TraceEnabled = true,
                    InvokeItems  = new List <InvokeItem>(),
                };
                var item0 = new InvokeItem()
                {
                    Ready   = true,
                    Request = new InvokeRequest()
                    {
                        Url    = "http://www.baidu.com",
                        Method = "POST",
                        Body   = "abc",
                    },
                    Response = new InvokeResponse()
                    {
                    },
                    Script = "function postprocess(context, index, item) { if (item.Response.StatusCode==200) context.InvokeItems[1].Ready = true; }",
                };
                var item1 = new InvokeItem()
                {
                    Request = new InvokeRequest()
                    {
                        Url = "http://www.yipinapp.com",
                    },
                    Response = new InvokeResponse()
                    {
                    },
                    Script = "function preprocess(context, index, item) { logger.Info('preprocess'); item.Response.StatusCode=500; }\r\n function postprocess(context, index, item) { item.Response.Body = \"abc\"; item.Completed = true; logger.Error('postprocess'); }",
                };
                context.InvokeItems.Add(item0);
                context.InvokeItems.Add(item1);
            }
            else
            {
                var json = this.GetRequestContentJson() as JsonObject;
                context = InvokeContext.Deserialize(json);
            }

            UpdateInvokeItems(context);

            bool hasReadyItems = false;

            do
            {
                hasReadyItems = false;

                for (int index = 0; index < context.InvokeItems.Count; index++)
                {
                    var item = context.InvokeItems[index];
                    if (item.Ready && (!item.Completed))
                    {
                        hasReadyItems = true;

                        try
                        {
                            await RunInvokeItem(context, index);
                        }
                        catch (Exception ex)
                        {
                            context.LogTraceError("Failed to run invoke item " + index + " Exception:" + ex.ToString());
                        }

                        item.SetCompleted();
                    }
                }
            } while (hasReadyItems);

            var writer = new JsonWriter();

            InvokeContext.Serialize(writer, context, context.TraceEnabled ? Formats.BatchInvokeResultWithRequest : Formats.BatchInvokeResult);
            return(this.JsonResponseJson(0, "InvokeContext", writer.ToString()));
        }