Document doc = StaxUtils.read(handlerFileURL.openStream()); Element el = doc.getDocumentElement(); if (!"http://java.sun.com/xml/ns/javaee".equals(el.getNamespaceURI())
try { reader = StaxUtils.createXMLStreamReader((javax.xml.transform.Source)holder.value); Document document = StaxUtils.read(reader); createdSource = new StaxSource(StaxUtils.createXMLStreamReader(document)); payloadElementName = getPayloadElementName(document.getDocumentElement());
if (!(ds instanceof DOMSource)) { try { ds = new DOMSource(StaxUtils.read(ds)); } catch (XMLStreamException e) { throw new Fault(e);
public static Document read(File is) throws XMLStreamException, IOException { try (InputStream fin = Files.newInputStream(is.toPath())) { return read(fin); } } public static Document read(InputSource s) throws XMLStreamException {
public static Document read(File is) throws XMLStreamException, IOException { try (InputStream fin = Files.newInputStream(is.toPath())) { return read(fin); } } public static Document read(InputSource s) throws XMLStreamException {
public static Document read(File is) throws XMLStreamException, IOException { InputStream fin = new FileInputStream(is); try { return read(fin); } finally { fin.close(); } } public static Document read(InputSource s) throws XMLStreamException {
private Element readXmlDocument(Reader reader) { try { return StaxUtils.read(new InputSource(reader)).getDocumentElement(); } catch (Exception ex) { throw new IllegalStateException("Unable to read wadl", ex); } }
/** * Allows for multiple queries against the same stream by buffering to DOM */ public void setBuffering() { try { doc = StaxUtils.read(new StreamSource(stream)); stream = null; } catch (XMLStreamException e) { throw new Fault(e); } }
protected Element readToken(Message message, InputStream tokenStream) { try { Document doc = StaxUtils.read(new InputStreamReader(tokenStream, StandardCharsets.UTF_8)); return doc.getDocumentElement(); } catch (Exception ex) { throwFault("Assertion can not be read as XML document", ex); } return null; }
public Node invoke(String address, String transport, String message) throws Exception { byte[] bs = invokeBytes(address, transport, message); ByteArrayInputStream input = new ByteArrayInputStream(bs); return StaxUtils.read(input); } public Node invoke(String address, String transport, byte[] message) throws Exception {
public Node invoke(String address, String transport, byte[] message) throws Exception { byte[] bs = invokeBytes(address, transport, message); ByteArrayInputStream input = new ByteArrayInputStream(bs); return StaxUtils.read(input); }
public Map<String, ThreadingParameters> createThreadingParametersMap(String s, JAXBContext ctx) throws Exception { Document doc = StaxUtils.read(new StringReader(s)); List <ThreadingParametersIdentifiedType> threadingParametersIdentifiedTypes = UndertowSpringTypesFactory .parseListElement(doc.getDocumentElement(), new QName(UndertowHTTPServerEngineFactoryBeanDefinitionParser.HTTP_UNDERTOW_NS, "identifiedThreadingParameters"), ThreadingParametersIdentifiedType.class, ctx); return toThreadingParameters(threadingParametersIdentifiedTypes); }
public Map<String, ThreadingParameters> createThreadingParametersMap(String s, JAXBContext ctx) throws Exception { Document doc = StaxUtils.read(new StringReader(s)); List <ThreadingParametersIdentifiedType> threadingParametersIdentifiedTypes = JettySpringTypesFactory .parseListElement(doc.getDocumentElement(), new QName(JettyHTTPServerEngineFactoryBeanDefinitionParser.HTTP_JETTY_NS, "identifiedThreadingParameters"), ThreadingParametersIdentifiedType.class, ctx); return toThreadingParameters(threadingParametersIdentifiedTypes); }
private Document retrieveWsdlDocument(String hostname, String port) throws Exception { URL wsdlUrlLocalhost = new URL("http://" + hostname + ":" + port + "/SpringEndpoint?wsdl"); URLConnection urlConnection = wsdlUrlLocalhost.openConnection(); try (InputStream input = urlConnection.getInputStream()) { return StaxUtils.read(input); } }
private Document mapFromOld(Document doc) throws XMLStreamException { XMLStreamReader domReader = StaxUtils.createXMLStreamReader(doc); Map<String, String> inMap = new HashMap<>(); inMap.put("{" + WSDVersion.INSTANCE_1_0.getNamespace() + "}*", "{" + WSDVersion.INSTANCE_1_1.getNamespace() + "}*"); inMap.put("{" + WSDVersion.INSTANCE_1_0.getAddressingNamespace() + "}*", "{" + WSDVersion.INSTANCE_1_1.getAddressingNamespace() + "}*"); InTransformReader reader = new InTransformReader(domReader, inMap, null, false); doc = StaxUtils.read(reader); //System.out.println(StaxUtils.toString(doc)); return doc; }
protected void assertLogNotContains(String log, String xpath) throws XMLStreamException { String s = log.substring(log.indexOf("Payload: ") + 9); Document doc = StaxUtils.read(new StringReader(s)); Map<String, String> ns = new HashMap<>(); ns.put("wsa", "http://www.w3.org/2005/08/addressing"); ns.put("soap", "http://schemas.xmlsoap.org/soap/envelope/"); XPathUtils xpathu = new XPathUtils(ns); assertNull(xpathu.getValueNode(xpath, doc.getDocumentElement())); } protected void assertLogContains(String log, String xpath, String value) throws XMLStreamException {
@Test public void testWSDLImports() throws Exception { URL url = new URL("http://localhost:" + PORT + "/SoapContext/GreeterPort?wsdl"); Document doc = StaxUtils.read(url.openStream()); Map<String, String> ns = new HashMap<>(); ns.put("xsd", "http://www.w3.org/2001/XMLSchema"); Node nd = new XPathUtils(ns) .getValueNode("//xsd:import[@namespace='http://cxf.apache.org/greeter_control/types']", doc.getDocumentElement()); assertNotNull(nd); } @Test
private List<Element> checkWadlResourcesInfo(String baseURI, String requestURI, String schemaRef, int size) throws Exception { WebClient client = WebClient.create(requestURI + "?_wadl&_type=xml"); Document doc = StaxUtils.read(new InputStreamReader(client.get(InputStream.class), StandardCharsets.UTF_8)); return checkWadlResourcesInfo(doc, baseURI, schemaRef, size); } private List<Element> checkWadlResourcesInfo(Document doc, String baseURI, String schemaRef, int size)
public void invokingEndpoint(WebRequest req) throws Exception { WebResponse response = newClient().getResponse(req); assertEquals("text/xml", response.getContentType()); assertTrue("utf-8".equalsIgnoreCase(response.getCharacterSet())); Document doc = StaxUtils.read(response.getInputStream()); assertNotNull(doc); addNamespace("h", "http://apache.org/hello_world_soap_http/types"); assertValid("/s:Envelope/s:Body", doc); assertValid("//h:sayHiResponse", doc); }
public void invokingEndpoint(WebRequest req) throws Exception { WebResponse response = newClient().getResponse(req); assertEquals("text/xml", response.getContentType()); assertTrue("utf-8".equalsIgnoreCase(response.getCharacterSet())); Document doc = StaxUtils.read(response.getInputStream()); assertNotNull(doc); addNamespace("h", "http://apache.org/hello_world_soap_http/types"); assertValid("/s:Envelope/s:Body", doc); assertValid("//h:sayHiResponse", doc); }