well, I have written an extension to Axis which is able to cope with typed 
Collections (jdk 1.5). Type mappings now work just like typed arrays. I had to 
extend a bunch of Axis-classes, e.g. Emitter, Types, BeanSerializer, ...

The main problem was, that it is not possible to determine the component type 
of a collection by just inspecting the Collection class alone. Rather you need 
a java.reflect.Field or java.reflect.Method object that defines the Collection 
as type or parameter/return type.

e.g.

in case of a method which returns List<String>

Type gt = method.getGenericReturnType();
if( gt instanceof ParameterizedType )
{
   return (Class)((ParameterizedType)gt).getActualTypeArguments()[0];
}

returns String.class

please correct me if there is an easier way to do it!

balazs

-------- Original-Nachricht --------
Datum: Thu, 29 Mar 2007 15:51:39 +0200
Von: [EMAIL PROTECTED]
An: axis-user@ws.apache.org
Betreff: mapping typed collections

Hello!

I have an RPC-encoded-style service using Axis 1.4 which contains typed lists 
(jdk1.5 generics) as parameters/return types, e.g.

List<String> hello( List<Moo> li )

As well as typed lists within service parameters, e.g.

int ciao( Foo foo ) 

where Foo has a member List<Boo> boo;

Unfortunately the generated WSDL does not contain a definition of Moo and Boo, 
and every List is mapped with an ArrayOf_xsd_anyType.

I understand that it is not possible to determine the element type of a 
Collection during runtime (unlike in case of a regular array). But maybe it is 
possible to provide a hint to the Axis framework how to map typed collections 
correctly. Can I pass some sort of metadata to the engine to achieve the 
correct handling?

I tried the getTypeDesc() construct, but it does not seem to help. I'm not 
afraid of overrding Axis code, just please someone tell me where to start!

Thanks!

Balazs

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to