You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Li, Weiye" <We...@STJUDE.ORG> on 2007/08/09 18:28:24 UTC

How to get an array of object on client side

Hello:

 

I'm new to Axis. I wrote a simple web service using Axis2 v1.3 to do the
database CRUD. On a request-response DII call my service will return an
array of object (JavaBean). I had trouble on this point. The code piece
is:

 

RPCServiceClient serviceClient = new RPCServiceClient();

Options options = serviceClient.getOptions();

EndpointReference targetEPR = new EndpointReference(SERVICE_EPR);

options.setTo(targetEPR);

 

QName opName = new QName(SCHEMA_NAME_SPACE, "getLocations");

Object[] opArgs = new Object[]{};

// here is the point of confusion

Class[] returnType = new Class[] {

      LocationBean.class

};          

Object[] response = serviceClient.invokeBlocking(opName, opArgs,
returnType);

 

Since the "getLocations" return an array of LocationBean, I don't know
how to set the returnType, The code above can only get first element in
the array. i.e.., response array has only one element. Closely monitor
the SOAP response message turned out all elements in that array was
included in SOAP.

 

If I set returnType this way:

Class[] returnType = new Class[] {

      LocationBean.class, LocationBean.class

};

The response array will have two return objects. However it is not the
way it should be: how can I know the # of objects to return? And if the
service returns 100 object, I need to repeat LocationBean.class 100
times!

 

Anyone can help? Thanks a lot

 

Will