SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
envelope.getBody().addChild(ADBBeanUtil.getOMElement(bean));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
OMOutputFormat format = new OMOutputFormat();
format.setDoOptimize(true);
envelope.serialize(buffer, format);
// envelope.serialize(System.out, format);
String contentType = format.getContentTypeForMTOM("text/xml");
Attachments attachments = new Attachments(new ByteArrayInputStream(buffer.toByteArray()), contentType);
assertEquals(countDataHandlers(bean) + 1, attachments.getAllContentIDs().length);
MTOMStAXSOAPModelBuilder builder = new MTOMStAXSOAPModelBuilder(StAXUtils.createXMLStreamReader(attachments.getRootPartInputStream()), attachments);