2009/4/2 Joe-D Morrison <joe-d.morri...@db.com>:
> Earlier I asked about customizing XML serialization in CXF and got some
> helpful suggestions, but I left out an important detail.  I need to write
> a "streaming" SOAP service that returns an enormous amount of XML without
> storing the entire response in memory at any time.

I've done this by using JAX-WS Provider<StreamSource> services which
build their own XML payload and don't bother with databinding.

http://cwiki.apache.org/CXF20DOC/provider-services.html

e.g. I have a service which reads records from a database (via
Hibernate but that's not important), converts them into XML and
streams them directly into the message body. There's a data access
object which iterates over the record list, converting it into XML,
and supplying an iterator of its own which returns Strings containing
XML fragments (one per database row).

Then I have another class:

http://biotext.org.uk/iteratorreader-streaming-character-data-from-an-iterator/

which wraps this Iterator<String> in a Reader, and the web service
wraps this Reader in a StreamSource (providing a header and footer
which contain the start and end message part elements) and returns it
to CXF for streaming back to the client. That link explains it in
slightly more detail.

Disclaimer: I have no idea whether this is the best way to do it or not :-)

Andrew.

-- 
:: http://biotext.org.uk/ ::

Reply via email to