public void testElementPullStreamAndOMExpansion2() throws Exception {
// Create a reader sourced from a message containing an interesting payload
XMLStreamReader reader = StAXUtils.createXMLStreamReader(getTestResource("soap/soapmessageWithXSI.xml"));
// Create a builder connected to the reader
StAXBuilder builder = (StAXBuilder)OMXMLBuilderFactory.createStAXSOAPModelBuilder(
reader);
// Create a custom builder to store the sub trees as a byte array instead of a full tree
ByteArrayCustomBuilder customBuilder = new ByteArrayCustomBuilder("utf-8");
// Register the custom builder on the builder so that they body payload is stored as bytes
builder.registerCustomBuilderForPayload(customBuilder);
// Create an output stream
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
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(),