Search in sources :

Example 6 with XPath

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;
}
Also used : XPath(org.jaxen.XPath) DOMXPath(org.jaxen.dom.DOMXPath) DOMXPath(org.jaxen.dom.DOMXPath) Iterator(java.util.Iterator) SimpleNamespaceContext(org.jaxen.SimpleNamespaceContext)

Aggregations

XPath (org.jaxen.XPath)6 SOAPMessage (javax.xml.soap.SOAPMessage)3 ArrayList (java.util.ArrayList)2 Text (javax.xml.soap.Text)2 Project (com.intellij.openapi.project.Project)1 URL (java.net.URL)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Node (javax.xml.soap.Node)1 XPathSupport (org.intellij.plugins.xpathView.support.XPathSupport)1 CachedVariableContext (org.intellij.plugins.xpathView.util.CachedVariableContext)1 SimpleNamespaceContext (org.jaxen.SimpleNamespaceContext)1 XPathSyntaxException (org.jaxen.XPathSyntaxException)1 DOMXPath (org.jaxen.dom.DOMXPath)1 JDOMXPath (org.jaxen.jdom.JDOMXPath)1 SAXPathException (org.jaxen.saxpath.SAXPathException)1 Attribute (org.jdom.Attribute)1 Document (org.jdom.Document)1 SAXBuilder (org.jdom.input.SAXBuilder)1 EntityResolver (org.xml.sax.EntityResolver)1