我无法使用Java(使用Bonita Open Solution BPM)解析SOAP响应.
我有以下SOAP响应(在IBM Content Manager中搜索文档; SOAP响应返回1个匹配的文档)
我想获取文件名(ICCFileName =“ Golem_Artikel.txt”)和此文件的网址(< cm:URL value =“ http://cmwin01.ebusiness.local:9080 / icmrm / ICMResourceManager / A10. .)在使用Java的字符串变量中.我读了几篇有关如何执行此操作的文章(Can’t process SOAP response,How to do the Parsing of SOAP Response),但没有成功,这是我尝试的方法:
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
// Clean response xml document
responseDocumentBody.normalizeDocument();
// Get result node
NodeList resultList = responseDocumentBody.getElementsByTagName("ICCSPArchivSuche");
Element resultElement = (Element) resultList.item(0);
String XMLData = resultElement.getTextContent();
// Check for empty result
if ("Data Not Found".equalsIgnoreCase(XMLData))
return null;
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource inputSource = new InputSource();
inputSource.setCharacterStream(new StringReader(XMLData));
Document doc = documentBuilder.parse(inputSource);
Node node = doc.getDocumentElement();
String result = doc.getNodeType();
return result;
从Bonita,我仅获得responseDocumentBody或responseDocumentEnvelope(org.w3c.dom.Document)作为Web服务响应.因此,我需要从SOAP正文导航到我的变量.如果有人可以帮我,我会很高兴.
最好的祝福
如果觉得《java soap 解析_用Java解析SOAP响应》对你有帮助,请点赞、收藏,并留下你的观点哦!