Examples of XMLSource


Examples of org.apache.cxf.jaxrs.ext.xml.XMLSource

        String endpointAddress =
            "http://localhost:9080/the/thebooks5/bookstore/books/xslt";
        WebClient wc = WebClient.create(endpointAddress);
        wc.accept("application/xhtml+xml").path(666).matrix("name2", 2).query("name", "Action - ");
        XMLSource source = wc.get(XMLSource.class);
        Map<String, String> namespaces = new HashMap<String, String>();
        namespaces.put("xhtml", "http://www.w3.org/1999/xhtml");
        Book2 b = source.getNode("xhtml:html/xhtml:body/xhtml:ul/xhtml:Book", namespaces, Book2.class);
        assertEquals(666, b.getId());
        assertEquals("CXF in Action - 2", b.getName());
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.xml.XMLSource

            return docRequired ? doc : new DOMSource(doc);
        } else if (StreamSource.class.isAssignableFrom(source)
                   || Source.class.isAssignableFrom(source)) {
            return new StreamSource(is);
        } else if (XMLSource.class.isAssignableFrom(source)) {
            return new XMLSource(is);
        }
       
        throw new IOException("Unrecognized source");
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.xml.XMLSource

    @Test
    public void testGetBook123XMLSource() throws Exception {
        String baseAddress = "http://localhost:9092/test/services/rest";
        WebClient client = WebClient.create(baseAddress);
        client.path("/bookstore/123").accept(MediaType.APPLICATION_XML_TYPE);
        XMLSource source = client.get(XMLSource.class);
        source.setBuffering(true);
        Book b = source.getNode("/Book", Book.class);
        assertEquals(123, b.getId());
        assertEquals("CXF in Action", b.getName());
        b = source.getNode("/Book", Book.class);
        assertEquals(123, b.getId());
        assertEquals("CXF in Action", b.getName());
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.xml.XMLSource

        String endpointAddress =
            "http://localhost:9080/the/bookstore1/books/html/123";
        WebClient client = WebClient.create(endpointAddress);
        client.accept("text/html");
        WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(100000000);
        XMLSource source = client.accept("text/html").get(XMLSource.class);
        Map<String, String> namespaces = new HashMap<String, String>();
        namespaces.put("xhtml", "http://www.w3.org/1999/xhtml");
        namespaces.put("books", "http://www.w3.org/books");
        String value = source.getValue("xhtml:html/xhtml:body/xhtml:ul/books:bookTag", namespaces);
        assertEquals("CXF Rocks", value);
        String ct = client.getResponse().getMetadata().getFirst("Content-Type").toString();
        assertEquals("text/html", ct);
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.xml.XMLSource

        String endpointAddress =
            "http://localhost:9080/the/bookstore4/books/html/123";
        WebClient client = WebClient.create(endpointAddress);
        client.accept("text/html");
        WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(100000000);
        XMLSource source = client.accept("text/html").get(XMLSource.class);
        Map<String, String> namespaces = new HashMap<String, String>();
        namespaces.put("xhtml", "http://www.w3.org/1999/xhtml");
        namespaces.put("books", "http://www.w3.org/books");
        String value = source.getValue("xhtml:html/xhtml:body/xhtml:ul/books:bookTag", namespaces);
        assertEquals("CXF Rocks", value);
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.xml.XMLSource

        String endpointAddress =
            "http://localhost:" + PORT + "/the/thebooks5/bookstore/books/xslt";
        WebClient wc = WebClient.create(endpointAddress);
        wc.accept("application/xhtml+xml").path(666).matrix("name2", 2).query("name", "Action - ");
        XMLSource source = wc.get(XMLSource.class);
        Map<String, String> namespaces = new HashMap<String, String>();
        namespaces.put("xhtml", "http://www.w3.org/1999/xhtml");
        Book2 b = source.getNode("xhtml:html/xhtml:body/xhtml:ul/xhtml:Book", namespaces, Book2.class);
        assertEquals(666, b.getId());
        assertEquals("CXF in Action - 2", b.getName());
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.xml.XMLSource

        InputStream is = ResourceUtils.getResourceStream(loc, BusFactory.getDefaultBus());
        if (is == null) {
            return;
        }
        ByteArrayInputStream bis = IOUtils.loadIntoBAIS(is);
        XMLSource source = new XMLSource(bis);
        source.setBuffering(true);
        String targetNs = source.getValue("/*/@targetNamespace");

        Map<String, String> nsMap =
            Collections.singletonMap("xs", XmlSchemaConstants.XSD_NAMESPACE_URI);
        String[] elementNames = source.getValues("/*/xs:element/@name", nsMap);
        externalQnamesMap.put(targetNs, Arrays.asList(elementNames));
        String schemaValue = source.getNode("/xs:schema", nsMap, String.class);
        externalSchemasCache.add(schemaValue);
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.xml.XMLSource

        public StringSchemaWriter(List<String> schemas, List<URI> links, UriInfo ui) {

            this.theSchemas = new LinkedList<String>();
            // we'll need to do the proper schema caching eventually
            for (String s : schemas) {
                XMLSource source = new XMLSource(new ByteArrayInputStream(s.getBytes()));
                source.setBuffering(true);
                Map<String, String> locs = getLocationsMap(source, "import", links, ui);
                locs.putAll(getLocationsMap(source, "include", links, ui));
                String actualSchema = !locs.isEmpty() ? transformSchema(s, locs) : s;
                theSchemas.add(actualSchema);
            }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.xml.XMLSource

        Book b = new Book("CXF rocks", 123L);
        Response r = store.addBook(b);
        assertNotNull(r);
        InputStream is = (InputStream)r.getEntity();
        assertNotNull(is);
        XMLSource source = new XMLSource(is);
        source.setBuffering(true);
        assertEquals(124L, Long.parseLong(source.getValue("Book/id")));
        assertEquals("CXF rocks", source.getValue("Book/name"));
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.xml.XMLSource

    @Test
    public void testGetBook123XMLSource() throws Exception {
        String baseAddress = "http://localhost:" + PORT + "/test/services/rest";
        WebClient client = WebClient.create(baseAddress);
        client.path("/bookstore/123").accept(MediaType.APPLICATION_XML_TYPE);
        XMLSource source = client.get(XMLSource.class);
        source.setBuffering(true);
        Book b = source.getNode("/Book", Book.class);
        assertEquals(123, b.getId());
        assertEquals("CXF in Action", b.getName());
        b = source.getNode("/Book", Book.class);
        assertEquals(123, b.getId());
        assertEquals("CXF in Action", b.getName());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.