MVC4微信支付报警例子

来源:互联网 发布:第一个python web开发 编辑:程序博客网 时间:2024/05/16 07:59
public ActionResult Alert()        {            //模拟请求            string requestXML = "<xml>"+                        "<AppId><![CDATA[wxf8b4f85f3a794e77]]></AppId>"+                        "<ErrorType>1001</ErrorType>"+                        "<Description><![CDATA[错识描述]]></Description>"+                        "<AlarmContent><![CDATA[错误详情]]></AlarmContent>"+                        "<TimeStamp>1393860740</TimeStamp>"+                        "<AppSignature><![CDATA[f8164781a303f4d5a944a2dfc68411a8c7e4fbea]]></AppSignature>"+                        "<SignMethod><![CDATA[sha1]]></SignMethod>" +                    "</xml>";            byte[] bytes = Encoding.UTF8.GetBytes(requestXML);            //写入内存流            MemoryStream testRequestStream = new MemoryStream(bytes);            //读取XML(可以替换为XDocument doc = XDocument.Load(Request.InputStream);意思是读取请求中的内容)            XDocument doc = XDocument.Load(testRequestStream);            //获取appidXML元素            var childAppid = doc.Descendants("AppId").FirstOrDefault();            //获取appid的值            string appid = childAppid.Value;            //获取Description的值            string Description = doc.Descendants("Description").FirstOrDefault().Value;            return Content("appid:"+appid+"Description:"+Description);        }

0 0
原创粉丝点击