jQuery in Action, 2nd edition*
The moose likes Web Services and the fly likes Is it possible to return an array of objects from a web service? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Is it possible to return an array of objects from a web service?" Watch "Is it possible to return an array of objects from a web service?" New topic
Author

Is it possible to return an array of objects from a web service?

Huw Morgan
Greenhorn

Joined: Mar 07, 2006
Posts: 23
I have been trying to do this for a while now, and I have come to the conclusion that it may be impossible. To demonstate what I want to do I enclose a simple java file [1]. I have deployed this with Axis 2 and I enclose the responce [2], it is obciously not wat I want.

Is it porrible to do this? If so, how?

Thanks for any help,

[1]


[2]
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
The problem could be the object SampleElement is not mapped to Axis2.

Instead of you generating the skeleton, aar, wsdl... Try to use axis2 supplied tools like Java2WSDL or WSDL2Java to generate the serverside and stub code for you. This will helps you get the all the return and input types mapped properly.

Regards
Balaji


Spritle Software Blogs
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Here is the axis2 tools link http://ws.apache.org/axis2/tools/index.html
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
You are correct you cannot return a pure, naked array - the array must always be "contained". In XML sequences are only permitted inside another complexType - you cannot have a "free-floating" sequence.

Depending on the databinding that you are using another layer of containment may also be required if you need to distinguish between an empty array and a null array.

Web services programming tips and tricks: Array gotcha -- null array vs. empty array.

Basically it is a good idea to create web service interfaces contract first - that way the web service contract isn't influenced by the choice of the service implementation language (in this case Java).
 
 
subject: Is it possible to return an array of objects from a web service?
 
Similar Threads
Indexed properties and Validation
struts2 list of radio buttons
JAXB Problem
Edit Soap tags response using Axis2 in eclipse
customize xml response in axis2