Using JDK5 enums with Axis 1.2

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Using JDK5 enums with Axis 1.2

Jay Glanville
I have a web application with an embedded instance of Axis 1.2 final in
it.  We were using JDK 1.4.2, but in preparation for JDK 5, I started
running some tests.  One of those tests was to create a JDK5 enumeration
and have my web service run/use it.  Just a note, my web service now has
both JDK 1.4-style enumerations (enum pattern) and JDK 5 enumerations.
The service implementation looks something like this:
   public EnumPattern[] getEnumPatern( EnumPattern z ) {...}
   public EnumType[] getEnumType( EnumType z ) {...}
The EnumPattern is the 1.4 implementation using the pattern, while
EnumType is an instance of a JDK 5 enumeration type.  I used both arrays
and single instances so that the WSDL generators would generate
definitions of both single and array.

When I let Axis auto generate the WSDL file, I get definitions for
EnumPattern[], EnumPattern and EnumType[], but not EnumType.  There is
also no warnings/errors in my logs (in 1.2-rc3, axis would warn me about
classes without public constructors, etc).

When I use the Ant Java2WSDL to generate the WSDL file, I get the
following warning on the output stream:
   [axis-java2wsdl] - The class com.nci.common.enums.EnumType
   does not contain a default constructor, which is a
   requirement for a bean class.  The class cannot be converted
   into an xml schema type.  An xml schema anyType will be used
   to define this class in the wsdl file.
Now this is VERY interesting, as the enum type definition in JDK 5
REQUIRES the enumeration's constructor to be private.  But then of
course, if I remember correctly, the ant tasks don't actually look at
the typeMappings to help determine if a bean is actually a bean or an
enumeration.  So, I'm assuming that this is a false error.

Now, it may be that I'm configuring the serializer/deserializer wrong.
I mean, it's happened before, and I'm sure it'll happen again.  So, here
is what I'm using in my server-config.wsdd file:
   <typeMapping qname="ns:EnumType"
I've done some extensive searching on the mailing lists (both user and
developer), with rather muddied results.  Some say things work, others
say things don't.  Many problems were identified with enumerations and
Axis 1.2-rc1 or rc2, but nothing specific to the final 1.2.
Can someone explicitly confirm or deny for me whether or not Axis
supports JDK5 during runtime?


Jay Dickon Glanville