Package org.apache.cxf.helpers

Examples of org.apache.cxf.helpers.XPathUtils


        Element schemaElement = schemaInfo.getElement();
        // we need an import for every namespace except the main one.
        String schemaNamespace = schemaInfo.getNamespaceURI();
        Map<String, String> queryPrefixMap = new HashMap<String, String>();
        queryPrefixMap.put("xs", WSDLConstants.NS_SCHEMA_XSD);
        XPathUtils xpu = new XPathUtils(queryPrefixMap);
        NamespacePrefixList schemaPrefixes = schemaInfo.getSchema().getNamespaceContext();
        for (String prefix : schemaPrefixes.getDeclaredPrefixes()) {
            String namespace = schemaPrefixes.getNamespaceURI(prefix);
            if (!namespace.equals(schemaNamespace)
                && !namespace.equals(WSDLConstants.NS_SCHEMA_XSD)
                && !xpu.isExist("xs:import[@namespace='" + namespace + "']",
                                 schemaElement,
                                 XPathConstants.NODE)) {
                Element importElement = XMLUtils.createElementNS(schemaElement.getOwnerDocument(),
                                                                 WSDLConstants.NS_SCHEMA_XSD,
                                                                 "import");
View Full Code Here


        return supportsDOM;
    }
   
    private void setStackTrace(Fault fault, Message msg) {
        Map<String, String> ns = new HashMap<String, String>();
        XPathUtils xu = new XPathUtils(ns);
        String ss = (String) xu.getValue("/" + Fault.STACKTRACE + "/text()", fault.getDetail(),
                XPathConstants.STRING);
        List<StackTraceElement> stackTraceList = new ArrayList<StackTraceElement>();
        if (!StringUtils.isEmpty(ss)) {
            StringTokenizer st = new StringTokenizer(ss, "\n");
            while (st.hasMoreTokens()) {
View Full Code Here

        if (nd instanceof Document) {
            nd = ((Document)nd).getDocumentElement();
        }
        Map<String, String> ns = new HashMap<String, String>();
        ns.put("ns2", "http://cxf.apache.org/policytest/DoubleIt");
        XPathUtils xp = new XPathUtils(ns);
        Object o = xp.getValue("//ns2:DoubleItResponse/doubledNumber", nd, XPathConstants.STRING);
        assertEquals(XMLUtils.toString(nd), "50", o);
    }
View Full Code Here

            if (el instanceof Document) {
                el = ((Document)el).getDocumentElement();
            }
            Map<String, String> ns = new HashMap<String, String>();
            ns.put("ns2", "http://cxf.apache.org/policytest/DoubleIt");
            XPathUtils xp = new XPathUtils(ns);
            String o = (String)xp.getValue("//ns2:DoubleIt/numberToDouble", el, XPathConstants.STRING);
            int i = Integer.parseInt(o);
           
            String req = "<ns2:DoubleItResponse xmlns:ns2=\"http://cxf.apache.org/policytest/DoubleIt\">"
                + "<doubledNumber>" + Integer.toString(i * 2) + "</doubledNumber></ns2:DoubleItResponse>";
            return new StreamSource(new StringReader(req));
View Full Code Here

        assertNotNull(doc);
       
        Map<String, String> ns = new HashMap<String, String>();
        ns.put("soap", Soap11.SOAP_NAMESPACE);
        ns.put("ns2", "http://apache.org/hello_world_soap_http/types");
        XPathUtils xu = new XPathUtils(ns);
        Node body = (Node) xu.getValue("/soap:Envelope/soap:Body", doc, XPathConstants.NODE);
        assertNotNull(body);
        String response = (String) xu.getValue("//ns2:sayHiResponse/ns2:responseType/text()",
                                               body,
                                               XPathConstants.STRING);
        assertEquals("Bonjour", response);
    }
View Full Code Here

        assertNotNull(doc);
       
        Map<String, String> ns = new HashMap<String, String>();
        ns.put("soap", Soap11.SOAP_NAMESPACE);
        ns.put("ns2", "http://apache.org/hello_world_soap_http/types");
        XPathUtils xu = new XPathUtils(ns);
        Node body = (Node) xu.getValue("/soap:Envelope/soap:Body", doc, XPathConstants.NODE);
        assertNotNull(body);
        String response = (String) xu.getValue("//ns2:greetMeResponse/ns2:responseType/text()",
                                               body,
                                               XPathConstants.STRING);
        assertEquals("Hello cxf", response);
    }
View Full Code Here

        assertNotNull(doc);
       
        Map<String, String> ns = new HashMap<String, String>();
        ns.put("soap", Soap11.SOAP_NAMESPACE);
        ns.put("ns2", "http://apache.org/hello_world_soap_http/types");
        XPathUtils xu = new XPathUtils(ns);
        Node body = (Node) xu.getValue("/soap:Envelope/soap:Body", doc, XPathConstants.NODE);
        assertNotNull(body);
        String response = (String) xu.getValue("//ns2:greetMeResponse/ns2:responseType/text()",
                                               body,
                                               XPathConstants.STRING);
        assertEquals("Hello cxf (was CeltixFire)", response);
    }
View Full Code Here

            Map<String, String> ns = new HashMap<String, String>();
            ns.put("wsdl", WSDLConstants.NS_WSDL11);
            ns.put("wsu",
                   "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
            ns.put("wsp", Constants.URI_POLICY_13_NS);
            XPathUtils xpu = new XPathUtils(ns);
            //org.apache.cxf.helpers.XMLUtils.printDOM(wsdl);
            check(xpu, wsdl, "/wsdl:definitions/wsdl:service/wsdl:port", "TestImplPortPortPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/", "TestInterfacePortTypePolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/", "echoIntPortTypeOpPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:input",
                  "echoIntPortTypeOpInputPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:output",
                  "echoIntPortTypeOpOutputPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/", "TestImplServiceSoapBindingBindingPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/", "echoIntBindingOpPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:input",
                  "echoIntBindingOpInputPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:output",
                  "echoIntBindingOpOutputPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:service/", "TestImplServiceServicePolicy");
           
            assertEquals(1,
                         xpu.getValueList("/wsdl:definitions/wsdl:binding/wsdl:operation/"
                                              + "wsp:PolicyReference[@URI='#echoIntBindingOpPolicy']", wsdl)
                             .getLength());
           
            EndpointPolicy policy = bus.getExtension(PolicyEngine.class)
                .getServerEndpointPolicy(s.getEndpoint().getEndpointInfo(), null, null);
View Full Code Here

            Map<String, String> ns = new HashMap<String, String>();
            ns.put("wsdl", WSDLConstants.NS_WSDL11);
            ns.put("wsu",
                   "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
            ns.put("wsp", Constants.URI_POLICY_13_NS);
            XPathUtils xpu = new XPathUtils(ns);
            //org.apache.cxf.helpers.XMLUtils.printDOM(wsdl);
            check(xpu, wsdl, "/wsdl:definitions/wsdl:service/wsdl:port", "TestInterfacePortPortPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/", "TestInterfacePortTypePolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/", "echoIntPortTypeOpPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:input",
                  "echoIntPortTypeOpInputPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:output",
                  "echoIntPortTypeOpOutputPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/",
                  "TestInterfaceServiceSoapBindingBindingPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/", "echoIntBindingOpPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:input",
                  "echoIntBindingOpInputPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:output",
                  "echoIntBindingOpOutputPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:service/", "TestInterfaceServiceServicePolicy");
           
            assertEquals(1,
                         xpu.getValueList("/wsdl:definitions/wsdl:binding/wsdl:operation/"
                                              + "wsp:PolicyReference[@URI='#echoIntBindingOpPolicy']", wsdl)
                             .getLength());
           
        } finally {
            bus.shutdown(true);
View Full Code Here

        Map<String, String> map = new HashMap<String, String>();
        map.put("xsd", "http://www.w3.org/2001/XMLSchema");
        map.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
        map.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
        map.put("tns", "http://cxf.apache.org/test/HelloService");
        XPathUtils util = new XPathUtils(map);
       
        Element el = (Element)util.getValueNode("//xsd:element[@ref]", doc);
        assertNotNull(el);
        assertTrue(el.getAttribute("ref").contains("item"));
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.helpers.XPathUtils

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.