首页 > 微信 > 详细

微信接受请求的接口

时间:2015-01-29 09:13:04      阅读:359      评论:0      收藏:0      [点我收藏+]
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; }
        }
    }
}

 

微信接受请求的接口

原文:http://www.cnblogs.com/slu182/p/4257792.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!