xmlspring-wsjaxb2woodstox

Using Woodstox with Spring-WS


When Spring-WS is used with JAXB for marshalling & unmarshalling, which streaming implementation is used internally?

response = (AResponse) webSvcTemplate.marshalSendAndReceive(request);

Read through SO queries and found that Woodstox is faster than JAXB. However, as I use Spring-WS, Spring literally takes care of the entire stuff that happens during marshalling and unmarshalling.

Question is how do I force Spring-WS to use Woodstox streaming API ?


Solution

  • When Spring-WS is used with JAXB for marshalling & unmarshalling, which streaming implementation is used internally?

    That depends on which WebServiceMessageFactory you've enabled. By default Spring-WS uses SAAJ (i.e. SaajSoapMessageFactory), which is based on DOM, and does not do any streaming at all as the entire XML structure is stored in memory. You can switch from SAAJ to Axiom (i.e. AxiomSoapMessageFactory), which does do StAX-based streaming. See the reference docs.

    Read through SO queries and found that Woodstox is faster than JAXB.

    That really depends on the context: size of the messages, hardware you're running on, etc. From personal experience, I've found that streaming is not significantly faster for 'small' to 'medium' sized SOAP messages.

    Also, you are comparing apples with oranges here: Woodstox is a StAX implementation, an XML parser. JAXB is a marshaling library, which builds Java objects from XML using parsers like StAX (but also SAX, and DOM).

    However, as I use Spring-WS, Spring literally takes care of the entire stuff that happens during marshalling and unmarshalling.

    Isn't it great? ;)

    Question is how do I force Spring-WS to use Woodstox streaming API ?

    Simply putting Woodstox on the class path should be enough, Spring-WS will pick it up automatically. You would have to switch to Axiom (see above) though, before you can notice any difference. And even then I would wager that the performance difference is not that big.