public void serializeAndConsume(OutputStream output, OMOutputFormat format)
throws XMLStreamException {
MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(output, format, false);
try {
try {
internalSerialize(new StAXSerializer((OMSerializable)this, writer), format, false);
} catch (OutputException ex) {
throw (XMLStreamException)ex.getCause();
}
// TODO: the flush is necessary because of an issue with the lifecycle of MTOMXMLStreamWriter
writer.flush();