• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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]
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Balaji Loganathan
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the axis2 tools link http://ws.apache.org/axis2/tools/index.html
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
reply
    Bookmark Topic Watch Topic
  • New Topic