This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Services and the fly likes returning multiple values in a web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "returning multiple values in a web service" Watch "returning multiple values in a web service" New topic
Author

returning multiple values in a web service

Nelo Angelo
Ranch Hand

Joined: Jul 25, 2011
Posts: 44

I am designing a web-service using java and eclipse which returns the user details who are marked as customer in the database.


GetData.java



LoginDetailsVO.java


On running the code I get object references like these: [[Ljava.lang.Object;@4d5575, [Ljava.lang.Object;@5585dc]
How can I get valid user details in place of object references? Please advice.



[Thumbnail for result.jpg]


I love java but she hates me... :'(
Santhosh ayiappan
Ranch Hand

Joined: Jan 30, 2007
Posts: 80

You need to construct a XML with all the user details and return the xml as String to the caller.
Nelo Angelo
Ranch Hand

Joined: Jul 25, 2011
Posts: 44

Santhosh ayiappan wrote:You need to construct a XML with all the user details and return the xml as String to the caller.


Hi Santhosh,

Thanks for the reply. Would you please provide an example so that I could gain some insight as I am very new to web-services.

Or perhaps you could provide me a link where I could learn how to handle these cases.

Thanks again.
Santhosh ayiappan
Ranch Hand

Joined: Jan 30, 2007
Posts: 80

You can use the XML Parser as you wish (DOM/SAX) and construct a Document object.

Then parse the LoginDetailsVO object and extract the values and set them to the Document object and finally you can convert the Document object to String and return that.

This link would be a starter for you. Dom Parser

Regards
Santhosh
Anurag Verma
Ranch Hand

Joined: Mar 30, 2012
Posts: 124

i think you are getting proper result & just printing it on screen in an incorrect way. just add a toString() method to your POJO class returning the username (or something you can identify) from it. you can also add LoggingInInterceptor & LoggingOutInterceptor to see what is going out & what is coming back to the client.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: returning multiple values in a web service