mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-02-19 06:36:28 +08:00
#651 WxMpXmlMessage增加allFieldsMap属性, 用于存放所有xml属性和值。
This commit is contained in:
@@ -3,6 +3,7 @@ package me.chanjar.weixin.mp.bean.message;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
@@ -11,6 +12,7 @@ import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.util.XmlUtils;
|
||||
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
|
||||
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
|
||||
import me.chanjar.weixin.mp.util.crypto.WxMpCryptUtil;
|
||||
@@ -33,6 +35,11 @@ import me.chanjar.weixin.mp.util.xml.XStreamTransformer;
|
||||
public class WxMpXmlMessage implements Serializable {
|
||||
private static final long serialVersionUID = -3586245291677274914L;
|
||||
|
||||
/**
|
||||
* 使用dom4j解析的存放所有xml属性和值的map.
|
||||
*/
|
||||
private Map<String, Object> allFieldsMap;
|
||||
|
||||
///////////////////////
|
||||
// 以下都是微信推送过来的消息的xml的element所对应的属性
|
||||
///////////////////////
|
||||
@@ -562,7 +569,9 @@ public class WxMpXmlMessage implements Serializable {
|
||||
public static WxMpXmlMessage fromXml(String xml) {
|
||||
//修改微信变态的消息内容格式,方便解析
|
||||
xml = xml.replace("</PicList><PicList>", "");
|
||||
return XStreamTransformer.fromXml(WxMpXmlMessage.class, xml);
|
||||
final WxMpXmlMessage xmlMessage = XStreamTransformer.fromXml(WxMpXmlMessage.class, xml);
|
||||
xmlMessage.setAllFieldsMap(XmlUtils.xml2Map(xml));
|
||||
return xmlMessage;
|
||||
}
|
||||
|
||||
public static WxMpXmlMessage fromXml(InputStream is) {
|
||||
|
||||
Reference in New Issue
Block a user