Hi, What is required for the DataHandler is some sort of input soure. So as long as you have a DataSource that represents the binary then you are fine! Here is a code sample for doing that
.... previous code FileDataSource dataSource = new FileDataSource("yourfile.zip"); expectedDH = new DataHandler(dataSource); OMText textData = fac.createOMText(expectedDH, true); .... This should create a proper Datahandler for the OMText to attach the file Ajith On 5/4/06, Michele Mazzucco <[EMAIL PROTECTED]> wrote:
Hi Ajith, thanks for your reply. My questions, actually, is: In the MTOM sample application, the client has this metho private OMElement createEnvelope(String fileName) throws Exception { DataHandler expectedDH; OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my"); OMElement data = fac.createOMElement("mtomSample", omNs); OMElement image = fac.createOMElement("image", omNs); Image expectedImage; expectedImage = new ImageIO() .loadImage(new FileInputStream(inputFile)); ImageDataSource dataSource = new ImageDataSource("test.jpg", expectedImage); expectedDH = new DataHandler(dataSource); OMText textData = fac.createOMText(expectedDH, true); image.addChild(textData); OMElement imageName = fac.createOMElement("fileName", omNs); if (fileName != null) { imageName.setText(fileName); } //OMElement wrap = fac.createOMElement("wrap",omNs); // data.addChild(image); data.addChild(imageName); data.addChild(image); //data.addChild(wrap); return data; } If I need to send something different from an image, what function should I call instead of Image expectedImage; expectedImage = new ImageIO().loadImage(new FileInputStream(inputFile)); FileOutputStream imageOutStream = new FileOutputStream(fileName); new ImageIO().saveImage("image/jpeg", actualObject, imageOutStream); ? And on the server side, what function should I call instead of Image actualObject = new ImageIO().loadImage(actualDH.getDataSource() .getInputStream()); ? Thanks, Michele Ajith Ranabahu wrote: > Hi, > As far as the content is concerned the zip file is a "binary" file > just like the image file. All you have to do is read the file through > a file input stream and then create a new DataSource using that > inputstream. > > Ajith > > > On 5/4/06, Michele Mazzucco <[EMAIL PROTECTED]> wrote: >> Hi all, >> >> the tutorial show how to send images with MTOM, but how can I send >> binary files with MTOM (say .zip files)? >> >> Thanks in advance, >> Michele >> > > > -- > Ajith Ranabahu
-- Ajith Ranabahu