/**
* XML报文解析
* @param docStr
*/
private Map<String, Object> analysisXmlStr(String xmlStr) {
try {
Map<String, Object> analysisResultMap = new HashMap<>();
if (StringUtils.isEmpty(xmlStr)) {
return analysisResultMap;
}
org.dom4j.Document payResponseDoc = DocumentHelper.parseText(xmlStr);
org.dom4j.Element rootElement = payResponseDoc.getRootElement();
// Header
Node headerNode = rootElement.selectSingleNode("Header");
String status = headerNode.selectSingleNode("Status").getStringValue();
// Response
Node responseNode = rootElement.selectSingleNode("Response");
if (null == responseNode) {
return analysisResultMap;
}
Node orderStatusNode = responseNode.selectSingleNode("OrderStatus");
if (null == orderStatusNode) {
return analysisResultMap;
}
String orderStatus = orderStatusNode.getStringValue();
String platformCode = responseNode.selectSingleNode("PlatformCode").getStringValue();
String payAmount = responseNode.selectSingleNode("PayAmount").getStringValue();
String realPayAmount = responseNode.selectSingleNode("RealPayAmount").getStringValue();
String orderId = responseNode.selectSingleNode("OrderId").getStringValue();
// Response - TradeList
Node tradeListNode = responseNode.selectSingleNode("TradeList");
String batchNo = tradeListNode.selectSingleNode("TradeIfo").selectSingleNode("BatchDetailNo").getStringValue(); // 封装
analysisResultMap.put("status", status);
analysisResultMap.put("orderStatus", orderStatus);
analysisResultMap.put("platformCode", platformCode);
analysisResultMap.put("payAmount", payAmount);
analysisResultMap.put("realPayAmount", realPayAmount);
analysisResultMap.put("orderId", orderId);
analysisResultMap.put("batchNo", batchNo);
return analysisResultMap;
} catch (DocumentException e) {
logger.error("报文解析异常!", e);
}
return null;
}

  

最新文章

  1. 解决java.io.IOException: HTTPS hostname wrong: should be
  2. Highcharts指南
  3. Eclipse SVN插件与TortoiseSVN的对应关系及下载链接
  4. 【BUG】wego购物分享系统未登陆分享宝贝时查看宝贝自动新增产品数据
  5. apache 80端口部属多站点配置
  6. JVM内存区域划分
  7. 保护模式下GDTR,LDTR,全局描述符表,局部描述符表和选择器的关系
  8. javascript进击(四)HTML DOM
  9. LOOPS
  10. Zookeeper以Windows服务安装运行
  11. 大道至简第一章--java伪代码读后感
  12. 如何访问IPV6?很简单,几个命令行即可。
  13. matplotlib 刻度,坐标轴不可见
  14. CRLF攻击的一篇科普:新浪某站CRLF Injection导致的安全问题(转)
  15. Boost中的智能指针(转)
  16. RGMII_PHY测试笔记1 基于开发板MiS603-X25
  17. powerdesigner-ER图建模
  18. c# 递归函数使用案例
  19. asp.net MVC中防止跨站请求攻击(CSRF)的ajax用法
  20. Spring 2.0

热门文章

  1. ubuntu 查看已安装软件命令
  2. Angular响应式表单验证输入(跨字段验证、异步API验证)
  3. 如何将视频作为Windows桌面动态壁纸,两步就可以搞定!
  4. svn ssh方式避免每次输入密码
  5. [Vue warn]: Do not use built-in or reserved HTML elements as component id: text 错误的解决办法
  6. 公司官网百度搜素优化(www.curetech.cc)
  7. VUE使用axios数据请求时报错 TypeError: Cannot set property &#39;xxxx&#39; of undefined 的解决办法
  8. win10 打开剪切板失败 拒绝访问 已解决!!
  9. BigQuery 如何帮助大规模交付业务型企业提供物联网解决方案
  10. 【Hive 元数据和真实数据-TAB_COL_STATS记录错误问题】