DOM4J对SOAP的返回信息解析
来源:互联网 发布:知乎回答如何删除 编辑:程序博客网 时间:2024/05/17 07:10
用DOM4J的XML解析式拿不到节点的。所以网上利用DOM4J提供的VisitorSupport解决此问题。不废话,直接看代码:
package com.starhub.util;import org.dom4j.Document;import org.dom4j.DocumentException;import org.dom4j.DocumentHelper;import org.dom4j.Element;import org.dom4j.VisitorSupport;public class SOAPUtil extends VisitorSupport{private String eaId;private String tranId;private String response;private String msisdn;public void visit(Element node) {if ("EAID".equals(node.getName())) {this.setEaId(node.getText());}else if("Response".equals(node.getName())){this.setResponse(node.getText());}else if("TranID".equals(node.getName())){this.setTranId(node.getText());}else if("MSISDN".equals(node.getName())){this.setMsisdn(node.getText());}}public static void main(String[] args) {String soapResponse = "<SOAP-ENV:Envelope\r\n" +"xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\""+" SOAP-ENV:encodingStyle=\"\">"+"<SOAP-ENV:Body>"+"<EAID>GameCode_ext</EAID>"+"<TranID>11102</TranID>"+"<Response>0100</Response>"+"</SOAP-ENV:Body>"+"</SOAP-ENV:Envelope>";SOAPUtil util = new SOAPUtil();try {util.analysis(soapResponse);} catch (DocumentException e) {e.printStackTrace();}System.out.println(util.getEaId());}public void analysis(String soapContent) throws DocumentException {Document doc = DocumentHelper.parseText(soapContent);doc.accept(this);}public String getEaId() {return eaId;}public void setEaId(String eaId) {this.eaId = eaId;}public String getTranId() {return tranId;}public void setTranId(String tranId) {this.tranId = tranId;}public String getResponse() {return response;}public void setResponse(String response) {this.response = response;}public String getMsisdn() {return msisdn;}public void setMsisdn(String msisdn) {this.msisdn = msisdn;}}
- DOM4J对SOAP的返回信息解析
- soap发送报文请求和dom4j解析XML并且获得指定名称的节点信息
- dom4j解析soap xml
- dom4j解析soap报文
- dom4j对xml的解析
- java调用webservice天气预报(SOAP请求的方式获取天气信息并解析返回的XML)
- java调用webservice天气预报(SOAP请求的方式获取天气信息并解析返回的XML)
- java调用webservice天气预报(SOAP请求的方式获取天气信息并解析返回的XML)
- JSON 对Google API返回的信息进行解析
- xml解析-dom4j对XPATH的支持
- 对xml文件的解析dom4j
- DOM4j对xml解析
- dom4j解析soap型消息xml
- dom4j解析字符串型soap.xml文件
- 用dom4j解析xml,soap报文
- cxf解析soap信息,获取SOAP消息客户端传递的鉴权信息
- 采用DOM4J中的SAXReader解析webservice返回的XML文件
- dom4j使用XPath解析XML返回null的解决方法
- MySQL重装时出现start service失败的解决
- poj 1273 Ford_fulkerson
- 计算机网络 全双工 半双工 单工
- 常用SQL语句示例
- 我的学习51单片机的经历
- DOM4J对SOAP的返回信息解析
- Android AsyncTask理解
- 解析短信
- 甘特图选型
- QueryPerformanceCounter 程序运行时间的开销探讨
- 第一页
- 使用不同框架调用WebService
- Oracle 数据流系统架构
- 实验6_图形用户界面高级组件及线程的编写