I have another question regarding Lists being the returned class.
I have been able to get a List of strings being returned from my webservice
and it is working fine.
What if I have a List of User objects being returned from the webservice.
User is a java class I have written. How does Axis send me this List object.
Do I have to write a serializer or deserializer for the User class.

Any help is greatly appreciated.

Thanks
Vaishakhi
----- Original Message -----
From: "Vaishakhi Ajmera" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 19, 2002 3:26 PM
Subject: Re: Class Cast Exception using return type as List


> I downloaded the 04-19-02 nightly build.
> Anyway, I just changed every occurrence of List to ArrayList in both the
> webservice and the client class and Lo! It worked!!!!
>
> Thanks so much for all your help.
>
> ----- Original Message -----
> From: "Glen Daniels" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, April 19, 2002 3:06 PM
> Subject: RE: Class Cast Exception using return type as List
>
>
> >
> > Hm - that looks like it should work fine.  Are you using up-to-date Axis
> source?
> >
> > --Glen
> >
> > > -----Original Message-----
> > > From: Vaishakhi Ajmera [mailto:[EMAIL PROTECTED]]
> > > Sent: Friday, April 19, 2002 3:46 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: Class Cast Exception using return type as List
> > >
> > >
> > > Thanks for your reply Glen,
> > > I tried using both the setReturnType and setReturnClass but
> > > still got the
> > > ClassCastException
> > > This is what my webservice looks like
> > >
> > > import java.util.*;
> > > //import com.ardec.ebf.usermgr.*;
> > >
> > > public class UserList1
> > > {
> > >  private ArrayList userList=new ArrayList();
> > >
> > >  public List getUserList()
> > >  {
> > >   userList.add(new String("Vaishakhi Ajmera"));
> > >   userList.add(new String("Rabia Malik"));
> > >   return userList;
> > >  }
> > >
> > > }
> > > My client class calls the getUserList method. This is what
> > > the method that
> > > calls the webservice in my client class looks like
> > >
> > > protected String doExecute() throws Exception
> > >    {
> > >     String endpoint = "http://localhost:8080/axis/UserList1.jws";;
> > >
> > >     Service  service = new Service();
> > >       Call     call    = (Call) service.createCall();
> > >
> > >       call.setTargetEndpointAddress( new java.net.URL(endpoint) );
> > >       call.setOperationName( "getUserList" );
> > >
> > >       call.setReturnClass( java.util.List.class );
> > >       call.setReturnType(XMLType.SOAP_ARRAY);
> > >
> > >       listOfUsers = (ArrayList) call.invoke( new Object [] {});
> > >
> > >
> > >   return SUCCESS;
> > >    }
> > >
> > > So as you can see my webservice returns a List object. How do
> > > I make my
> > > service return a SOAP array. I am ending you the code so that
> > > you can point
> > > out anything that u see I am doing wrong. Hope this helps you solve my
> > > problem.
> > >
> > > This is great help and I surely appreciate it.
> > > Thanks
> > >
> > > Vaishakhi
> > >
> > > ----- Original Message -----
> > > From: "Glen Daniels" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Friday, April 19, 2002 2:25 PM
> > > Subject: RE: Class Cast Exception using return type as List
> > >
> > >
> > > >
> > > > Actually, the call.setReturnClass() method removes the need for the
> > > convert() (that's the whole point of that method).
> > > >
> > > > Vaishakhi, are you sure your service is actually returning
> > > a SOAP array?
> > > Also, you need to specify both the return type and the return class, I
> > > believe.
> > > >
> > > > --Glen
> > > >
> > > > > -----Original Message-----
> > > > > From: Vidyanand Murunikkara [mailto:[EMAIL PROTECTED]]
> > > > > Sent: Friday, April 19, 2002 3:16 PM
> > > > > To: [EMAIL PROTECTED]
> > > > > Subject: RE: Class Cast Exception using return type as List
> > > > >
> > > > >
> > > > > Hi
> > > > >
> > > > > I remember someone mentioning in the list that for List/Vector the
> > > > > return value from the call.invoke(...) is an object array.
> > > > > To convert it to some thing that u want u would use the
> > > convert method
> > > > > in org.apache.axis.utils.JavaUtils.
> > > > >
> > > > > Hope this helps
> > > > > Vidyanand
> > > > >
> > > > >
> > > > >
> > > > > -----Original Message-----
> > > > > From: Vaishakhi Ajmera [mailto:[EMAIL PROTECTED]]
> > > > > Sent: Friday, April 19, 2002 11:17 AM
> > > > > To: [EMAIL PROTECTED]
> > > > > Subject: Class Cast Exception using return type as List
> > > > >
> > > > >
> > > > > I have followed the instructions in the mailing lists and
> > > used these
> > > > > options
> > > > > to get a List as return type from a web service
> > > > >
> > > > > call.setReturnClass ( java.util.List.class)
> > > > > List ls = (List)call.invoke( new Object[] {} );
> > > > >
> > > > > or
> > > > >
> > > > > call.setReturnType( XMLType.SOAP_ARRAY);
> > > > > ArrayList ls = (ArrayList)call.invoke( new Object[] {} );
> > > > >
> > > > > Both the above combination of statements give me a
> > > > > java.lang.ClassCastException: [Ljava.lang.Object;
> > > > > .
> > > > > How should I go about then to get a java.util.List as
> > > return type from
> > > > > my
> > > > > webservice.
> > > > >
> > > > > Thanks
> > > > > Vaishakhi
> > > > >
> > > > >
> > >

Reply via email to