aspose file tools*
The moose likes Web Services and the fly likes Returning complex datatypes in a Web Service response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Returning complex datatypes in a Web Service response" Watch "Returning complex datatypes in a Web Service response" New topic
Author

Returning complex datatypes in a Web Service response

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9622
    
    2

Guys,

I have a Web Service that fetches some data from the database as an ArrayList of ObjectX where ObjectX has fields that holds the data read from the database. How should the response be such that it is easily interpretable by any client (.NET or any client as a mater of fact). In the end they are simply XML response but I would like to find out an easy way of representing this List of ObjectX. Any suggestions?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 530
    
    2

Joe Harry wrote:Guys,

I have a Web Service that fetches some data from the database as an ArrayList of ObjectX where ObjectX has fields that holds the data read from the database. How should the response be such that it is easily interpretable by any client (.NET or any client as a mater of fact). In the end they are simply XML response but I would like to find out an easy way of representing this List of ObjectX. Any suggestions?


Hi Joe,

In order to ensure interoperability Sun and Microsoft involved in WSIT/WCF projects. If you look into WSIT, documentation, you will understand how the mapping goes between Java and .Net world.


Regards
KumarRaja

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9622
    
    2

I was looking more in terms of complex object representations rather than the specifications laid out by WSIT. Anyways thanks for the pointer.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
One of the benefits of WS is their cross-platform and cross-language compatibility, so transferring Java-specific data types is not a good idea. Use arrays instead of Collections, and make sure that all objects (including nested ones) follow JavaBean conventions.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9622
    
    2

Yes, but arrays of what type?

I was also thinking of a comma seperated String.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
Arrays of objects that follow JavaBean conventions. If you implement it that way, the WSDL of the service should show nicely cross-platform compatible XSD types.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9622
    
    2

So I have something like this in place for the response part:



I assume that for the client it will represent some structure like this (assuming a java client)




I do now know how a .NET client would interpret this response. Does this hold good atleast for the java clients?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Returning complex datatypes in a Web Service response