public void testImageSampleSerialize() throws Exception {
outMTOMFile = new File(outFileName);
outBase64File = new File(outBase64FileName);
org.apache.axis2.om.impl.OMOutputImpl mtomOutput = new OMOutputImpl(new FileOutputStream(outMTOMFile),
true);
org.apache.axis2.om.impl.OMOutputImpl baseOutput = new OMOutputImpl(new FileOutputStream(outBase64File),
false);
OMNamespaceImpl soap = new OMNamespaceImpl(
"http://schemas.xmlsoap.org/soap/envelope/", "soap");
OMElement envelope = new OMElementImpl("Envelope", soap);
OMElement body = new OMElementImpl("Body", soap);
OMNamespaceImpl dataName = new OMNamespaceImpl(
"http://www.example.org/stuff", "m");
OMElement data = new OMElementImpl("data", dataName);
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);
envelope.addChild(body);
body.addChild(data);
data.addChild(binaryNode);
envelope.serialize(baseOutput);
baseOutput.flush();
envelope.serialize(mtomOutput);
mtomOutput.flush();
}