zoukankan      html  css  js  c++  java
  • 微信接受请求的接口

    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; }
            }
        }
    }
  • 相关阅读:
    java 生成随机字符串
    java 使用抽象工厂封装特性方法
    c3p0 连接池配置数据源
    sql 语法总结
    HttpRequestUtils post get请求
    Spring事务(1)
    Spring增强
    面试题
    Java的三种代理模式
    Spring中bean的作用域与生命周期
  • 原文地址:https://www.cnblogs.com/slu182/p/4257792.html
Copyright © 2011-2022 走看看