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?
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.