Hi,
I've found the problem.
First of all, I didn't explicitly set the content type to "image/png"
which explained the additional size, as jpeg headers were added:
DataSource ds = new ImageDataSource("image.png", "image/png", image);
Then however I had the problem that the received file size was smaller!
I compared the binaries and realized that some meta data was stripped
out. In some cases you might not care, but I think this can be quite
dangerous. I then used a FileDataSource instead of a ImageDataSource,
which solved the issues and now both files are exactly the same.
Server:
DataSource ds = new FileDataSource(file);
DataHandler dh = new DataHandler(ds);
OMText textData = factory.createOMText(dh, true);
Client:
DataHandler dh = (DataHandler) out.getDataHandler();
InputStream is = dh.getDataSource().getInputStream();
OutputStream os = new FileOutputStream("c:/dynamic-axis.png");
Anybody came across similar issues?
Cheerio,
patric
-----Original Message-----
From: Patric Fornasier
Sent: Thursday, 11 May 2006 2:06 PM
To: [email protected]
Subject: Loosing bytes with MTOM
Hi,
I'm sending a small png image from one server to another via MTOM. The
service and the client are both on the same machine.
The original size of the image is 6450 bytes. When the clients copies
the file to the file system however, the size of this copy is now 15083
bytes!
Funny enough, the received picture looks fine. It's just roughly 3 times
bigger.
Anybody got an idea what's going on here?
Here's the code for the server:
---
Image image = new ImageIO().loadImage(new FileInputStream(file));
DataSource dataSource = new ImageDataSource("image.png", image);
DataHandler dataHandler = new DataHandler(dataSource); // create an
optimized OMText node with the above DataHandler OMText textData =
factory.createOMText(dataHandler, true); out.addChild(textData);
And for the client:
---
OMText out = (OMText) response.getFirstOMChild();
DataHandler actualDH = (DataHandler) out.getDataHandler(); ImageIO io =
new ImageIO(); Image img =
io.loadImage(actualDH.getDataSource().getInputStream());
FileOutputStream imageOutStream = new
FileOutputStream("c:/dynamic-axis.png");
io.saveImage("image/png", img, imageOutStream);
Any hints are greatly appreciated!
Cheers,
patric
------------------------------------------------------------------------
--
This email and any attachments may be confidential. They may contain
legally privileged information or copyright material. You should not
read, copy, use or disclose them without authorisation. If you are not
an intended recipient, please contact us at once by return email and
then delete both messages. We do not accept liability in connection with
computer virus, data corruption, delay, interruption, unauthorised
access or unauthorised amendment. This notice should not be removed.