aspose file tools*
The moose likes Web Services and the fly likes Web service return complex data type vs.  XML string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Web service return complex data type vs.  XML string" Watch "Web service return complex data type vs.  XML string" New topic
Author

Web service return complex data type vs. XML string

Ricky Murphy
Ranch Hand

Joined: Oct 16, 2007
Posts: 31
Trying to compare the advantage of a web service method returning complex type or xml string in different situations.

It looks more generic to return a xml string to represent the complex type object, but if so, what is the need to make a web service return a complex data type (i.e. a pojo, a bean). I know there must be some sort of judgment (depends on the use case) to pick either one, what is your standards to determine which approach to choose?

Thank you

-Rick
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Ricky Murphy:
Trying to compare the advantage of a web service method returning complex type or xml string in different situations.


For one thing a SOAP web service always returns XML (or MIME for attachments).

The client decides what to do with that XML. Often code-generation tools are used to generate the code to un-marshal the XML to a bean (which may look nothing like the original complex type on the server) for expediency sake. However using static stubs is "static binding" which is a form of tight-coupling. Prodding the result XML with some XPath expressions to extract just the minimum amount of data required is a more loosely coupled approach (which requires more effort because it requires more manual coding). Finally the client could decide to simply keep the XML as is, especially if it uses an XML-based infrastructure, though it's likely that it would run an XSLT transformation on it to change it to a more suitable format for its domain.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web service return complex data type vs. XML string