baseOutputFormat.setDoOptimize(false);
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespaceImpl soap = new OMNamespaceImpl(
"http://schemas.xmlsoap.org/soap/envelope/", "soap", fac);
OMElement envelope = new OMElementImpl("Envelope", soap, fac);
OMElement body = new OMElementImpl("Body", soap, fac);
OMNamespaceImpl dataName = new OMNamespaceImpl(
"http://www.example.org/stuff", "m", fac);
OMElement data = new OMElementImpl("data", dataName, fac);
expectedImage =
new ImageIO().loadImage(
new FileInputStream(
getTestResourceFile(imageInFileName)));
ImageDataSource dataSource = new ImageDataSource("WaterLilies.jpg",
expectedImage);
expectedDH = new DataHandler(dataSource);
OMText binaryNode = new OMTextImpl(expectedDH, true, fac);
envelope.addChild(body);
body.addChild(data);
data.addChild(binaryNode);
envelope.serializeAndConsume(new FileOutputStream(outBase64File), baseOutputFormat);
envelope.serializeAndConsume(new FileOutputStream(outMTOMFile), mtomOutputFormat);
}