CxfPayload<SoapHeader> requestPayload = exchange.getIn().getBody(CxfPayload.class);
List<Element> inElements = requestPayload.getBody();
List<Element> outElements = new ArrayList<Element>();
// 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;
if (inElements.get(0).getLocalName().equals("echoBoolean")) {
documentString = ECHO_BOOLEAN_RESPONSE;
assertEquals("Get a wrong request", ECHO_BOOLEAN_REQUEST, request);
} else {
assertEquals("Get a wrong request", ECHO_REQUEST, request);
}
Document outDocument = converter.toDOMDocument(documentString);
outElements.add(outDocument.getDocumentElement());
// set the payload header with null
CxfPayload<SoapHeader> responsePayload = new CxfPayload<SoapHeader>(null, outElements);
exchange.getOut().setBody(responsePayload);
}