View Full Version : Use of DOMResult withing SaajSoapMessage
drobert_bfm
Jul 3rd, 2006, 02:16 PM
Isn't this a bit inefficient? I often have to return very large results, and the fact that the WebServiceMessage implementation (SaajSoapMessage) stores the results first in a DOM tree before rendering it to the OutputStream means that my service systematically runs out of memory.
Isn't there a way to directly serialize back to the client? I can do that with XFire.
Arjen Poutsma
Jul 6th, 2006, 08:21 AM
Isn't this a bit inefficient? I often have to return very large results, and the fact that the WebServiceMessage implementation (SaajSoapMessage) stores the results first in a DOM tree before rendering it to the OutputStream means that my service systematically runs out of memory.
Well, there is also the option of using the AxiomSoapMessage instead of the SaajSoapMessage. However, that doesn't really help you with large responses, only with large requests. The reason for this is that the AXIOM model only exposes a XMLStreamReader, and not a XMLStreamWriter.
Isn't there a way to directly serialize back to the client? I can do that with XFire.
There isn't a way (yet). In the future, I will look at the XFire code, and see whether I can create a MessageContext implementation based on that.
Cheers,
drobert_bfm
Jul 6th, 2006, 10:07 AM
XFire uses StAX throughout, and does require the creation of a XMLStreamReader to return to the engine. I've used two strategies to return the XMLStreamReader:
1. Use a XMLEventPipe (from the stax-utils project) to connect a XMLEventWriter to an XMLEventReader, and write a XMLStreamReader wrapper for the XMLEventReader, which converts between the two.
2. Directly write an XMLStreamReader to handle the generation of the output.
Both are a little unwieldy, but for the kind of document I'm looking at (~100M), it was more than worth it, both in terms of memory usage and of raw performance.
I saw AxiomSoapMessage, but I haven't figured how to use it yet. I'll take a closer look at it to see if I can do the same thing with it as I did with XFire.
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.