微信XML消息model定义之微信公众平台(一)

2020-07-27 16:48:47 浏览数 (1)

很简单的model定义。

代码语言:javascript复制
package cn.wx.server;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

/**
 * @title cn.wx.serverXMLMsg.java
 * @todo TODO
 * @author lpe234
 * @time 2014年5月21日下午2:13:27
 */
public class XMLMsg {
//普通消息基本变量
	String ToUserName;
	String FromUserName;
	String CreateTime;
	String MsgType;
	String Content;
	String MsgId;
//事件推送变量
	String Event;
//自定义菜单项
	String EventKey;
	

	public String getEventKey() {
		return EventKey;
	}

	public void setEventKey(String eventKey) {
		EventKey = eventKey;
	}

	public XMLMsg(String str) throws DocumentException {
		Document doc = DocumentHelper.parseText(str);
		Element root = doc.getRootElement();
		this.ToUserName = root.elementText("ToUserName");
		this.FromUserName = root.elementText("FromUserName");
		this.CreateTime = root.elementText("CreateTime");
		this.MsgType = root.elementText("MsgType");
		this.Content = root.elementText("Content");
		this.MsgId = root.elementText("MsgId");
		
		this.Event = root.elementText("Event");
		this.EventKey = root.elementText("EventKey");
	}

	public String getEvent() {
		return Event;
	}

	public void setEvent(String event) {
		Event = event;
	}

	public String getToUserName() {
		return ToUserName;
	}

	public void setToUserName(String toUserName) {
		ToUserName = toUserName;
	}

	public String getFromUserName() {
		return FromUserName;
	}

	public void setFromUserName(String fromUserName) {
		FromUserName = fromUserName;
	}

	public String getCreateTime() {
		return CreateTime;
	}

	public void setCreateTime(String createTime) {
		CreateTime = createTime;
	}

	public String getMsgType() {
		return MsgType;
	}

	public void setMsgType(String msgType) {
		MsgType = msgType;
	}

	public String getContent() {
		return Content;
	}

	public void setContent(String content) {
		Content = content;
	}

	public String getMsgId() {
		return MsgId;
	}

	public void setMsgId(String msgId) {
		MsgId = msgId;
	}
}

0 人点赞