writer = StAXUtils.createXMLStreamWriter(byteArrayOutputStream);
// Now use StreamingOMSerializer to write the input stream to the output stream
SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
SOAPBody body = env.getBody();
OMSourcedElement omse = (OMSourcedElement) body.getFirstElement();
StreamingOMSerializer serializer = new StreamingOMSerializer();
serializer.serialize(env.getXMLStreamReaderWithoutCaching(),
writer);
writer.flush();
String outputString = new String(byteArrayOutputStream.toByteArray());
assertTrue("Expected output was incorrect. Received:" + outputString,
outputString != null && !"".equals(outputString) && outputString.length() > 1);
assertTrue("Expected output was incorrect. Received:" + outputString,
outputString.contains("axis2:input"));
assertTrue("Expected output was incorrect. Received:" + outputString,
outputString.contains("This is some text"));
assertTrue("Expected output was incorrect. Received:" + outputString,
outputString.contains("Some Other Text"));
assertTrue("Expectation is that an OMSourcedElement was created for the payload",
omse != null);
assertTrue("Expectation is that the OMSourcedElement was not expanded by serialization ",
!omse.isExpanded());
}