Java Code Examples for org.apache.camel.component.cxf.CxfPayload#getBodySources()
The following examples show how to use
org.apache.camel.component.cxf.CxfPayload#getBodySources() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SoapPayloadConverterTest.java From syndesis with Apache License 2.0 | 6 votes |
@Test public void convertXmlToValidCxfPayload() throws IOException, XMLStreamException { // read XML bytes as an XML Document ByteArrayInputStream bis = new ByteArrayInputStream(IOUtils.readBytesFromStream(inputStream)); StaxUtils.read(bis); bis.reset(); // convert XML to CxfPayload final Exchange exchange = createExchangeWithBody(bis); final Message in = exchange.getIn(); requestConverter.process(exchange); final Object body = in.getBody(); Assertions.assertThat(body).isInstanceOf(CxfPayload.class); @SuppressWarnings("unchecked") final CxfPayload<Source> cxfPayload = (CxfPayload<Source>) body; // validate every header and body part XML for (Source headerPart : cxfPayload.getHeaders()) { validateXml(headerPart); } for (Source bodyPart : cxfPayload.getBodySources()) { validateXml(bodyPart); } }
Example 2
Source File: ResponseSoapPayloadConverter.java From syndesis with Apache License 2.0 | 5 votes |
@Override protected void convertMessage(Message in) { try { // get SOAP QNames from CxfPayload headers final SoapMessage soapMessage = in.getHeader("CamelCxfMessage", SoapMessage.class); final SoapVersion soapVersion = soapMessage.getVersion(); // get CxfPayload body final CxfPayload<?> cxfPayload = in.getMandatoryBody(CxfPayload.class); final List<?> headers = cxfPayload.getHeaders(); final List<Source> body = cxfPayload.getBodySources(); final OutputStream outputStream = newOutputStream(in, cxfPayload); final XMLStreamWriter writer = newXmlStreamWriter(outputStream); // serialize headers and body into an envelope writeStartEnvelopeAndHeaders(soapVersion, headers, writer); if (body != null && !body.isEmpty()) { writeBody(writer, body, soapVersion); } writer.writeEndDocument(); final InputStream inputStream = getInputStream(outputStream, writer); // set the input stream as the Camel message body in.setBody(inputStream); } catch (InvalidPayloadException | XMLStreamException | IOException e) { throw new RuntimeCamelException("Error parsing CXF Payload: " + e.getMessage(), e); } }