Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Returning complex datatypes in a Web Service response

 
Joe Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Kumar Raja
Ranch Hand
Posts: 547
2
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joe Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but arrays of what type?

I was also thinking of a comma seperated String.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic