Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make a web service return XML result  RSS feed

 
Ricky Murphy
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All:

I am writing a web service and one of the web methods needs to return a XML (either a string or an XML document) from a database call.

What I did was first to make a database call and got a ResultSet. I then looped through the ResultSet to fill in a Value Object for each row. I ended up with an array of ValueObject. I can return this set of value object and be done with it. However, the requirement asks for XML format. What do I need to do to convert this bean set into formatted XML? the final result could be a large string or a DOM Document? or any other suggestion to meet the requirement?

Thank you.

-RM
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can turn your VOs to XML document using something like XStream or manually marshaling them by appending attributes and elements (representing your VOs and their fields) to a StringBuffer. However more important issue is including the big xml document in your soap message.

You should consider using MOTM (JAX-WS 2+), attachments (SAAJ) or adding the xml document as a fragment of your soap message in order to get best possible performance.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!