Package org.apache.camel.converter.jaxp

Examples of org.apache.camel.converter.jaxp.XmlConverter


        return toInputStream(toString(buffer), exchange);
    }

    @Converter
    public static InputStream toInputStrean(DOMSource source) throws TransformerException, IOException {
        XmlConverter xmlConverter = createXmlConverter();
        return new ByteArrayInputStream(xmlConverter.toString(source).getBytes());
    }
View Full Code Here


        return new ByteArrayInputStream(xmlConverter.toString(source).getBytes());
    }

    private static synchronized XmlConverter createXmlConverter() {
        if (xmlConverter == null) {
            xmlConverter = new XmlConverter();
        }
        return xmlConverter;
    }
View Full Code Here

        successEndpoint.assertIsSatisfied();
        exceptionEndpoint.assertIsSatisfied();

        StreamSource body = (StreamSource) exceptionEndpoint.getExchanges().get(0).getIn().getBody();
        assertEquals("Ensure message re-readability in the exception handler", xml, new XmlConverter().toString(body));
    }
View Full Code Here

        NodeList nodeList = doc.getElementsByTagNameNS("http://www.w3.org/2001/04/xmlenc#", "EncryptedData");
        return nodeList.getLength() > 0;
    }
   
    private void logMessage(Exchange exchange, Document inDoc) throws Exception {
        XmlConverter converter = new XmlConverter();
        String xmlStr = converter.toString(inDoc, exchange);
        log.debug(xmlStr);  
    }
View Full Code Here

                        CxfPayload<SoapHeader> payload = exchange.getIn().getBody(CxfPayload.class);
                        List<Source> elements = payload.getBodySources();
                        assertNotNull("We should get the elements here", elements);
                        assertEquals("Get the wrong elements size", 1, elements.size());
                       
                        Element el = new XmlConverter().toDOMElement(elements.get(0));
                        elements.set(0, new DOMSource(el));
                        assertEquals("Get the wrong namespace URI", "http://camel.apache.org/pizza/types",
                                el.getNamespaceURI());
                           
                        List<SoapHeader> headers = payload.getHeaders();
View Full Code Here

    public static String elementToString(Element element) throws Exception {
        Map<String, String> namespaces = new HashMap<String, String>();
        visitNodesForNameSpace(element, namespaces);
        W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
        writeElement(element, writer, namespaces);
        XmlConverter converter = new XmlConverter();
        return converter.toString(converter.toDOMSource(writer.getDocument()), null);
    }
View Full Code Here

    }
   
    private Exchange sendSimpleMessageWithPayloadMessage(String endpointUri) {
        Exchange exchange = template.request(endpointUri, new Processor() {
            public void process(final Exchange exchange) throws Exception {
                Document document = new XmlConverter().toDOMDocument("<ns1:echo xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
                                 + "<arg0 xmlns=\"http://cxf.component.camel.apache.org/\">hello world</arg0>"
                                 + "</ns1:echo>");
                exchange.getIn().setBody(CxfPayloadConverter.documentToCxfPayload(document, exchange));
                exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, ECHO_OPERATION);
               
View Full Code Here

                        CxfPayload<SoapHeader> requestPayload = exchange.getIn().getBody(CxfPayload.class);
                        List<Source> inElements = requestPayload.getBodySources();
                        List<Source> outElements = new ArrayList<Source>();
                        // You can use a customer toStringConverter to turn a CxfPayLoad message into String as you want                       
                        String request = exchange.getIn().getBody(String.class);
                        XmlConverter converter = new XmlConverter();
                        String documentString = ECHO_RESPONSE;
                       
                        Element in = new XmlConverter().toDOMElement(inElements.get(0));
                        // Just check the element namespace
                        if (!in.getNamespaceURI().equals(ELEMENT_NAMESPACE)) {
                            throw new IllegalArgumentException("Wrong element namespace");
                        }
                        if (in.getLocalName().equals("echoBoolean")) {
                            documentString = ECHO_BOOLEAN_RESPONSE;
                            checkRequest("ECHO_BOOLEAN_REQUEST", request);
                        } else {
                            documentString = ECHO_RESPONSE;
                            checkRequest("ECHO_REQUEST", request);
                        }
                        Document outDocument = converter.toDOMDocument(documentString);
                        outElements.add(new DOMSource(outDocument.getDocumentElement()));
                        // set the payload header with null
                        CxfPayload<SoapHeader> responsePayload = new CxfPayload<SoapHeader>(null, outElements, null);
                        exchange.getOut().setBody(responsePayload);
                    }
View Full Code Here

        Map<String, String> ns = new HashMap<String, String>();
        ns.put("ns", MtomTestHelper.SERVICE_TYPES_NS);
        ns.put("xop", MtomTestHelper.XOP_NS);
       
        XPathUtils xu = new XPathUtils(ns);
        Element oute = new XmlConverter().toDOMElement(out.getBody().get(0));
        Element ele = (Element)xu.getValue("//ns:DetailResponse/ns:photo/xop:Include", oute,
                                           XPathConstants.NODE);
        String photoId = ele.getAttribute("href").substring(4); // skip "cid:"

        ele = (Element)xu.getValue("//ns:DetailResponse/ns:image/xop:Include", oute,
View Full Code Here

        //Helper class
    }
   
    @Converter
    public static String cxfPayloadToString(final CxfPayload<?> payload) {
        XmlConverter converter = new XmlConverter();
        StringBuilder buf = new StringBuilder();
        for (Object element : payload.getBody()) {
            String elementString = "";
            try {
                elementString = converter.toString((Element)element, null);
            } catch (TransformerException e) {
                elementString = element.toString();
            }
            buf.append(elementString);
        }
View Full Code Here

TOP

Related Classes of org.apache.camel.converter.jaxp.XmlConverter

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.