aspose file tools*
The moose likes Web Services and the fly likes Problem in returning an array in a container Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Problem in returning an array in a container" Watch "Problem in returning an array in a container" New topic
Author

Problem in returning an array in a container

ranjiith s
Greenhorn

Joined: Dec 12, 2003
Posts: 8
hey,

As my subject line says I'm facing a problem when I
try to send an array in a container with Axis 1.2.1.
Here are the steps I followed.

The service at the server side returns the following
UserCollection.
(getUsers method in the service class returns
UserCollection.)

UserCollection
{
User[] users;
}


I have defined an arrayMapping for 'User[]',
beanMapping for 'User' and beanMapping for
'UserCollection'.

I generate WSDL using (Java2WSDL) and client side java
files using (WSDL2Java).
As I run the client side code it failed with
ArrayStoreException with a message cannot convert to
bean etc.
(some serialization issue)

After going thru some forum discussions I added the
following (indexed) to the 'UserCollection' object.

UserCollection
{

User[] users;

setUsers(int i, User user)
{
users[i] = user;
}

getUsers(int i)
{
return users[i];
}
}
And things started working fine as expected. I was
able to use the webservice (got the list of users).

But the *ServiceSoapBindingImpl that got generated at
the client side had return as 'User[]' and not
'UserCollection' as defined at the server side.
I would like to know why is this and what needs to be
corrected for the above to return 'UserCollection' ?
(getUsers returned User[] instead of UserCollection.)

Being a newbie I tried the options (-u LITERAL and -y
WRAPPED) to figure out what difference it makes and if
it can help in the current scenario but it did not.

Looking forward for a response.

cheerz
ranjiith s
ranjiith s
Greenhorn

Joined: Dec 12, 2003
Posts: 8
I got this working with the '-w' option turned on when generating java from wsdl.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in returning an array in a container