Hi Lakshmi;

IMO Axis2 should handle this senario, If It do not, I think we have
met a bug. Can you create a simple Junit TestCase for the senario and
open a Jira Issue with it? (bug database)


Use a sample message as a string and remove the thread to simplefy the things
Thanks
Srinath

BTW (did you try to do the things in a one thread)?

Srinath



On 3/2/06, Lakshmi Chaparala <[EMAIL PROTECTED]> wrote:
> Our Axis2 service is currently implemented as you suggest and the xml is
> streaming back to the client ok.  The problem we're having is that the
> memory footprint on the server is larger than we'd like.
>
> We are creating a large xml result for a query in our Axis2 service
> implementation.  So we end up with a large xml result in a
> ByteArrayOutputStream that we need to send back to the client.  Using the
> standard implementation suggested below doubles the memory footprint on the
> server to create the OMElement that is returned by the service
> implementation method.  We'd like to be able to send the xml we have in
> memory over the wire without creating the OMElment objects.  Even better,
> we'd like to start streaming back the xml result as it is being created.  Is
> there any way to implement an Axis2 service that either has OMElement
> caching off when it streams back to the client or streams a result back to
> the client as it is being created?
>
> The code snippet below illustrates our failed attempts to make this work so
> far:
>
>                 //******* Standard Implementation
>                 final ByteArrayOutputStream os = new
> ByteArrayOutputStream();
>                 //This method simply fills the os with xml
>                 getDataObjectxml(snlModel, requiredAttrs, os);
>                 ByteArrayInputStream bais = new
> ByteArrayInputStream(os.toByteArray());
>                 StAXOMBuilder builder = new StAXOMBuilder(bais);
>                 //Turning off caching causes axis to hang on the retun
>                 //It can't handle a non-caching OMElement
> //                builder.setCache(false);
>                 dataOut = builder.getDocumentElement();
>
>                 //***** Multi-threaded implementation
> //                //set up the streaming connections
> //                final PipedOutputStream pos = new PipedOutputStream();
> //                PipedInputStream pis = new PipedInputStream(pos);
>                 //This implementation hangs here, attempting to create the
> xml stream reader
> //                XMLStreamReader parser =
> XMLInputFactory.newInstance().createXMLStreamReader(pis);
> //                StAXOMBuilder builder = new StAXOMBuilder(parser);
> //                dataOut = builder.getDocumentElement();
> //
> //                //write to the stream on a separate thread
> //                Runnable xmlRunnable = new Runnable() {
> //                    public void run() {
> //                        try {
> //                            getDataObjectxml(snlModel, requiredAttrs,
> pos);
> //                        } catch (Exception e) {
> //                            e.printStackTrace();  //To change body of
> catch statement use File | Settings | File Templates.
> //                        }
> //                    }
> //                };
> //                Thread serializerThread = new Thread(xmlRunnable);
> //                serializerThread.start();
>
>
> Lakshmi Chaparala
>
>
> -----Original Message-----
> From: Srinath Perera [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 02, 2006 11:07 AM
> To: [email protected]
> Subject: Re: Axis2 and Streaming
>
> If you create a OM element as follows by providing a  Stream, the
> stream is not really read
> unless you accsess the OMElement. So If you create a OM element like
> follwoing and use it in Axis2 .. it should do streaming
>
>          File file= new File("line-item.xml");
>          FileInputStream fis= new FileInputStream(file);
>          XMLInputFactory xif= XMLInputFactory.newInstance();
>          XMLStreamReader reader= xif.createXMLStreamReader(fis);
>          StAXOMBuilder builder= new StAXOMBuilder(reader);
>          OMElement lineItem= builder.getDocumentElement();
>
> See http://www-128.ibm.com/developerworks/library/x-axiom/ for more info
>
> --Srinath
>
>
>
>


--
============================
Srinath Perera:
   http://www.cs.indiana.edu/~hperera/
   http://www.bloglines.com/blog/hemapani

Reply via email to