• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to make a web service return XML result

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 531
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic