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 Stefan Freyr Stefansson <st...@hugsmidjan.is> on 2006/03/30 16:12:58 UTC

Enum -> xsd:restriction

Hello.

I've been working on this all morning and I'm just not solving this!

I apologise, I know this must have been asked before but none of the 
discussions I found solved my problem.

What I'm trying to do is generate a WSDL file from my Java source code. I want 
one of the parameters to a method in my service class to be an enumeration of 
values. From the web I've read that this should be possible by using the 
typesafe enumeration pattern in the Java code.

What I'm looking for is that in the end (after the WSDL has been generated) 
the aforementioned parameter contains the following "restriction" in the 
WSDL:

<xs:restriction base="xs:string">
  <xs:enumeration value="TRIBUNE_NATIVE"/>
</xs:restriction>

So for this I've created the EpgFormatEnum class which represents the 
enumeration and the actual service class which contains the following method:

  public void importEpgAssets(EpgFormatEnum format, String data){}

I created an ant build script that runs the <axis-java2wsdl> target on the 
service class.

I'm attaching the build file, enumeration class and complete output from 
running the Ant target for reference.

The problem is that whenever I run the java2wsdl target I get the following 
exception:

30.3.2006 13:57:16 org.apache.axis.wsdl.fromJava.Emitter writePartToMessage
WARNING: Please register a typemapping/beanmapping for 
'com.mycompany1.myproduct.management.EpgFormatEnum'
java.lang.ExceptionInInitializerError
	at sun.misc.Unsafe.ensureClassInitialized(Native Method)
	at 
sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
	at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
	at java.lang.reflect.Field.acquireFieldAccessor(Field.java:917)
	at java.lang.reflect.Field.getFieldAccessor(Field.java:898)
	at java.lang.reflect.Field.get(Field.java:357)
	at org.apache.axis.wsdl.fromJava.Types.writeEnumType(Types.java:1211)
	at 
org.apache.axis.encoding.ser.EnumSerializer.writeSchema(EnumSerializer.java:86)
	at org.apache.axis.wsdl.fromJava.Types.makeTypeElement(Types.java:1849)
...

The stacktrace suggests that Axis is trying to create some enumerated type but 
something is not going the way it should. If I change the method in the 
service class to receive simple types such as strings as parameters 
everything works fine.

Any help with this would be greatly appreciated.

Kind regards, Stefan Freyr.