Yup, in fact we already do this (in RPCProvider).
--G > -----Original Message----- > From: R J Scheuerle Jr [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, March 13, 2002 10:19 AM > To: [EMAIL PROTECTED] > Subject: Re: cvs commit: xml-axis/java/src/org/apache/axis/client > Call.java > > > Great addition Glen! > > Related question: > > If the server-side operation signature has a List parameter, > should the > runtime automatically convert the incoming Array to a List ? > > Rich Scheuerle > XML & Web Services Development > 512-838-5115 (IBM TL 678-5115) > > > > > [EMAIL PROTECTED] > > rg To: > [EMAIL PROTECTED] > cc: > > 03/13/2002 12:02 Subject: cvs > commit: xml-axis/java/src/org/apache/axis/client Call.java > AM > > Please respond to > > axis-dev > > > > > > > > > gdaniels 02/03/12 22:02:46 > > Modified: java/test/encoding TestArrayListConversions.java > java/src/org/apache/axis/client Call.java > Log: > Add a convenience API to Call to allow specifying a desired > return type > (i.e. Java class) to which we will attempt to convert the > result, and a > unit test which exercises it. > > Revision Changes Path > 1.15 +24 -0 > xml-axis/java/test/encoding/TestArrayListConversions.java > > Index: TestArrayListConversions.java > =================================================================== > RCS file: > /home/cvs/xml-axis/java/test/encoding/TestArrayListConversions.java,v > retrieving revision 1.14 > retrieving revision 1.15 > diff -u -r1.14 -r1.15 > --- TestArrayListConversions.java 28 Jan 2002 18:23:03 -0000 > 1.14 > +++ TestArrayListConversions.java 13 Mar 2002 06:02:46 -0000 > 1.15 > @@ -97,12 +97,36 @@ > if (!equals(v, ret)) assertEquals("Echo Array mangled the > result. Result is underneath\n" + ret, v, ret); > } > > + /** > + * Test the setReturnClass() API on Call by asking the > runtime to > + * give us back a Vector instead of an array. Confirm we get a > Vector > + * back, and that it matches the data we send. > + */ > + public void testReturnAsVector() throws Exception { > + LinkedList l = new LinkedList(); > + l.add("Linked list item #1"); > + l.add("Second linked list item"); > + l.add("This will be a SOAP Array then a Vector!"); > + > + call.setOperationName(new QName(SERVICE_NAME, > "echoArray")); > + call.setReturnClass(Vector.class); > + Object ret = call.invoke(new Object[]{l}); > + assertEquals("Return wasn't a Vector!", Vector.class, > ret.getClass()); > + Vector v = (Vector)ret; > + assertEquals("Sizes were different", l.size(), v.size()); > + for (int i = 0; i < l.size(); i++) { > + String s = (String)l.get(i); > + assertEquals("Value " + i + " didn't match", > s, v.get(i)); > + } > + } > + > public static void main(String[] args) { > TestArrayListConversions tester = new > TestArrayListConversions > ("TestArrayListConversions"); > try { > tester.testArrayConversion(); > tester.testLinkedListConversion(); > tester.testVectorConversion(); > + tester.testReturnAsVector(); > } catch (Exception e) { > e.printStackTrace(); > } > > > > 1.91 +28 -0 > xml-axis/java/src/org/apache/axis/client/Call.java > > Index: Call.java > =================================================================== > RCS file: > /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v > retrieving revision 1.90 > retrieving revision 1.91 > diff -u -r1.90 -r1.91 > --- Call.java 8 Mar 2002 17:27:08 -0000 1.90 > +++ Call.java 13 Mar 2002 06:02:46 -0000 1.91 > @@ -174,6 +174,9 @@ > // A place to store any client-specified headers > private Vector myHeaders = null; > > + // The desired return Java type, so we can do > conversions if needed > + private Class returnJavaType = null; > + > public static final String SEND_TYPE_ATTR = > "send_type_attr" ; > public static final String TRANSPORT_NAME = > "transport_name" ; > public static final String TRANSPORT_PROPERTY > = "java.protocol.handler.pkgs"; > @@ -728,6 +731,25 @@ > } > > /** > + * Sets the desired return Java Class. This is a > convenience method > + * which will cause the Call to automatically convert > return values > + * into a desired class if possible. For instance, we > return object > + * arrays by default now for SOAP arrays - you could specify: > + * > + * setReturnClass(Vector.class) > + * > + * and you'd get a Vector back from invoke() instead > of having to do > + * the conversion yourself. > + * > + * @param cls the desired return class. > + */ > + public void setReturnClass(Class cls) { > + returnJavaType = cls; > + // NOTE: Should be setting XML type based on this > as well at > some > + // point, so you can just use this. > + } > + > + /** > * Clears the list of parameters. > * @exception JAXRPCException - if > isParameterAndReturnSpecRequired > returns false, then > * removeAllParameters will throw JAXRPCException. > @@ -1596,6 +1618,12 @@ > if (log.isDebugEnabled()) { > log.debug(JavaUtils.getMessage("exit00", > > "Call::invoke(RPCElement)") > ); > + } > + > + // Convert type if needed > + if (returnJavaType != null && > + > !(returnJavaType.isAssignableFrom(result.getClass()))) { > + result = JavaUtils.convert(result, returnJavaType); > } > > return( result ); > > > > > >