码迷,mamicode.com
首页 > 其他好文 > 详细

接收的普通消息

时间:2015-01-20 21:45:25      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

package com.wanhua.weixin.model;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.io.xml.DomDriver;

/**
 * 接收的普通消息
 *
 * @author w_xfpenga
 *
 *         2014-12-28
 *
 */

@XStreamAlias("xml")
public class ReceMsg {

    // 开发者微信号
    @XStreamAlias("ToUserName")
    public String ToUserName;

    // 发送方帐号(一个OpenID)
    @XStreamAlias("FromUserName")
    public String FromUserName;

    // 消息创建时间 (整型)
    @XStreamAlias("CreateTime")
    public String CreateTime;

    // 消息类型:text,image,voice,video,location,link
    @XStreamAlias("MsgType")
    public String MsgType;

    // 文本消息内容
    @XStreamAlias("Content")
    public String Content;

    // 消息id,64位整型
    @XStreamAlias("MsgId")
    public String MsgId;

    /**
     * 将ReceMsg实体类转化成xml格式
     *
     * @author w_xfpenga
     * @param xml
     * @return
     *
     *         2014-12-28
     */
    public static ReceMsg parseReceMsgText(String xml) {
        XStream xstream = new XStream(new DomDriver());
        xstream.alias("xml", ReceMsg.class);
        // 开发者微信号
        xstream.aliasField("ToUserName", ReceMsg.class, "ToUserName");
        // 发送方帐号(一个OpenID)
        xstream.aliasField("FromUserName", ReceMsg.class, "FromUserName");
        // 消息创建时间 (整型)
        xstream.aliasField("CreateTime", ReceMsg.class, "CreateTime");
        // 消息类型:text,image,voice,video,location,link
        xstream.aliasField("MsgType", ReceMsg.class, "MsgType");
        // 文本消息内容
        xstream.aliasField("Content", ReceMsg.class, "Content");
        // 消息id,64位整型
        xstream.aliasField("MsgId", ReceMsg.class, "MsgId");
        ReceMsg receMsgText = (ReceMsg) xstream.fromXML(xml);
        return receMsgText;
    }

}

接收的普通消息

标签:

原文地址:http://www.cnblogs.com/xunfang123/p/4237137.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!