XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(inputFile));

 

OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), parser);

     

OMElement xmlDocElement = builder.getDocumentElement();

 

This assumes that “inputFile” is a java.io.File. This code can be found at:

 

http://ws.apache..org/axis2/0_95/OMTutorial.html

 

 

-----Original Message-----
From: Michele Mazzucco [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 04, 2006 6:36 AM
To: axis-user@ws.apache.org
Subject: Re: [Axis2] MTOM & binary content

 

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 = "" 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




This e-mail and any files transmitted with it are intended solely
for the use of the entity or individual(s) to whom they are
addressed and not for reliance upon by unintended recipients. If
you are not the intended recipient or the person responsible for
delivering the e-mail to the intended recipient be advised that you
have received this e-mail in error and that any use, dissemination,
forwarding, printing, or copying of this e-mail and any files
transmitted are strictly prohibited. If you have received this
e-mail in error please delete the entire email and immediately
notify us by email to the sender or by telephone to the AOC main
office number, (404) 656-5171. Thank you.

Reply via email to