use of org.jaxen.XPath in project tdi-studio-se by Talend.
the class SoapExecutor method createXPath.
/**
* Constructs XPath query over the SOAP message
* @param query XPath query
* @param response SOAP message
* @return XPath query
* @throws SOAPException in case of SOAP issue
* @throws JaxenException XPath problem
*/
public XPath createXPath(String query, SOAPMessage response) throws SOAPException, JaxenException {
//Uses DOM to XPath mapping
XPath xpath = new DOMXPath(query);
//Define a namespaces used in response
SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
SOAPPart sp = response.getSOAPPart();
SOAPEnvelope env = sp.getEnvelope();
SOAPBody bdy = env.getBody();
//Add namespaces from SOAP envelope
addNamespaces(nsContext, env);
//Add namespaces of top body element
Iterator bodyElements = bdy.getChildElements();
while (bodyElements.hasNext()) {
SOAPElement element = (SOAPElement) bodyElements.next();
addNamespaces(nsContext, element);
}
xpath.setNamespaceContext(nsContext);
return xpath;
}
Aggregations