很简单的model定义。
packagecn.wx.server; importorg.dom4j.Document; importorg.dom4j.DocumentException; importorg.dom4j.DocumentHelper; importorg.dom4j.Element; /** *@titlecn.wx.serverXMLMsg.java *@todoTODO *@authorlpe234 *@time2014年5月21日下午2:13:27 */ publicclassXMLMsg{ //普通消息基本变量 StringToUserName; StringFromUserName; StringCreateTime; StringMsgType; StringContent; StringMsgId; //事件推送变量 StringEvent; //自定义菜单项 StringEventKey; publicStringgetEventKey(){ returnEventKey; } publicvoidsetEventKey(StringeventKey){ EventKey=eventKey; } publicXMLMsg(Stringstr)throwsDocumentException{ Documentdoc=DocumentHelper.parseText(str); Elementroot=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"); } publicStringgetEvent(){ returnEvent; } publicvoidsetEvent(Stringevent){ Event=event; } publicStringgetToUserName(){ returnToUserName; } publicvoidsetToUserName(StringtoUserName){ ToUserName=toUserName; } publicStringgetFromUserName(){ returnFromUserName; } publicvoidsetFromUserName(StringfromUserName){ FromUserName=fromUserName; } publicStringgetCreateTime(){ returnCreateTime; } publicvoidsetCreateTime(StringcreateTime){ CreateTime=createTime; } publicStringgetMsgType(){ returnMsgType; } publicvoidsetMsgType(StringmsgType){ MsgType=msgType; } publicStringgetContent(){ returnContent; } publicvoidsetContent(Stringcontent){ Content=content; } publicStringgetMsgId(){ returnMsgId; } publicvoidsetMsgId(StringmsgId){ MsgId=msgId; } }