Announcement Announcement Module
Collapse
No announcement yet.
Use of DOMResult withing SaajSoapMessage Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use of DOMResult withing SaajSoapMessage

    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.

  • #2
    Originally posted by drobert_bfm
    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.

    Originally posted by drobert_bfm
    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,

    Comment


    • #3
      Direct serialization

      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.

      Comment

      Working...
      X