微信受信要求のインタフェース
4754 ワード
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; }
}
}
}