wood burning stoves 2.0*
The moose likes Web Services and the fly likes Better way to return XML document Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Better way to return XML document" Watch "Better way to return XML document" New topic
Author

Better way to return XML document

forums UseR
Ranch Hand

Joined: Feb 24, 2009
Posts: 169
Hello

How to go about converting a ResultSet into XML document, which I have to return as output from a Web Service.

I tested the Web Service by returning a String form of ResultSet, which looks like a huge ugly blob...

Any slick ideas please...

Thanks

Srinivas


Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Have you considered the following:
- For each row from the database, create and populate a JAXB bean class instance.
- Marshal the JAXB bean class instances to XML.
Best wishes!
forums UseR
Ranch Hand

Joined: Feb 24, 2009
Posts: 169
Thanks for the reply!

How should I return the final XML from the web service though?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
If you want to use the JAX-WS way, then you do not have to return the XML, but you can return, for instance, a JAXBSource object.
For an example on how to do that, see page 157 in this document: http://faq.javaranch.com/content/Exam-Objectives-5.pdf
Best wishes!
Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
srinivas chary wrote:How should I return the final XML from the web service though?

XML is also just an String data type, so web service method needs to return the String (XML). It works pretty well, see here Send XML data over web service.


My Blog
forums UseR
Ranch Hand

Joined: Feb 24, 2009
Posts: 169
Does anybody have ideas, on developing a web service that returns a XML file (converted from a result set, using JAXB)...


Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

Open the PDF given by Ivan and search for JAXBSource


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
forums UseR
Ranch Hand

Joined: Feb 24, 2009
Posts: 169
I searched on javaranch.com. And I came across this framework "XStream" which is quite easy to use. Boils down to couple lines of code...explained in this blog

Thanks for all your replies...

Srinivas


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Better way to return XML document
 
Similar Threads
How to make a web service return XML result
JAX-RPC or SAAJ
How to suppress Axis body content encoding
Namespace using Axis
help regarding bypassing Soap engine serialization deserialization