<xml>
<ToUserName>owW7Ns7iz7KxhMdywxkHKkviuw0E</ToUserName>
<FromUserName>gh_d44f5b13d5ab</FromUserName>
<CreateTime>1432878361740</CreateTime>
<MsgType>test</MsgType>
<Content>您发送的消息是hg</Content>
</xml>
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
req.setCharacterEncoding("UTF-8");
resp.setCharacterEncoding("UTF-8");
PrintWriter out = resp.getWriter();
try {
Map<String,String> map = MassageUtil.xmlToMap(req);
String fromUserName = map.get("ToUserName");
String toUserName = map.get("FromUserName");
String createTime = map.get("CreateTime");
String msgType = map.get("MsgType");
String content = map.get("Content");
String msgId = map.get("MsgId");
String message =null;
if("text".equals(msgType)){
Textmessage text = new Textmessage();
text.setFromUserName(fromUserName);
text.setToUserName(toUserName);
text.setMsgType("test");
text.setCreateTime(new Date().getTime());
//text.setMsgId(msgId);
text.setContent("您发送的消息是"+content);
message = MassageUtil.textMessageToXml(text);
}
System.out.println(message);
out.print(message);
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
out.close();
}
}