微信接受请求的接口

using System;

using System.Web;

using WeiXin.Core;

using Framework.Core;

using Newtonsoft.Json;



namespace WeiXin

{

    public class ReceiveHttpHandler : IHttpHandler

    {

        public void ProcessRequest(HttpContext context)

        {

            Logger.Write("request:" + context.Request.Url);

            string json = Newtonsoft.Json.JsonConvert.SerializeObject(context.Request.Params);

            try

            {

                if (context.Request.HttpMethod.ToLower() == "get")

                {

                    if (context.Request.Url.Query != string.Empty)

                    {

                        context.Response.Write(AccessTo.Validation(context));

                    }

                    else

                    {

                        context.Response.Write("success");

                    }

                }

                else

                {

                    string msgType = string.Empty;

                    string XML = RequestHelper.GetFormData();

                    //Logger.Write("XML:"+XML);

                    context.Items.Add("XML", XML);//module和handler之间组织和共享数据的集合

                    if (XML.Contains("<xml>"))

                    {

                        msgType = XmlHelper.XMLSelect(XML);                        

                    }

                    if (SpringContainer.ContainObject(msgType))

                    {

                        IProcess process = SpringContainer.GetObject<IProcess>(msgType);

                        process.Process();

                    }

                }

            }

            catch (Exception ex)

            {

                Logger.Write("接受请求失败,原因:" + ex.Message);               

            }

        }



        public bool IsReusable

        {

            get { return true; }

        }

    }

}

 

你可能感兴趣的:(接口)