When WSDL contains <xsd:extension> in type definitions, wsdl2java can generate non compilable code.
 
I have identified 2 cases of non compilable code :
 
- Generated class don't extends anything, but a constructor calling super(...) is generated (in this case super refer to java.lang.Object).
- Generated class don't extends anything, a constructor initializing each attribute is generated, but attribute name is replaced by "paramx".
 
I wrote the attached wsdl that reproduce the two cases. Please focus on the schema part only, rest of the file is a poor cut and paste.
 

After looking in the code (wsdl/toJava/JavaBeanWriter.java), my understanding is that tests to decide if a class extends another or not (and thus what constructor(s) must be outputted) are not coherent.
 
- In method writeFullConstructor(), a test type.isSimpleType() is done to check if constructor must be written.
- In method writeSimpleConstructors(), a test extendType != null is done to check if constructor must be written.
- In method getExtendsText() (which is called to generate the "extends" statement at the beginning of the class), a more complex test is used: (extendType != null) && !isUnion() && (!type.isSimpleType() || !extendType.isBaseType()) && (extendType.getDimensions().length() == 0)
 
Thats why sometimes writeFullConstructor emits a constructor calling super(...) even if the class don't really inherits from anything.
Or why writeSimpleConstructors emits a constructor to initialize every attributes even if the informations to write this constructor are not available.
 

If you agree with my analyze, i can open a JIRA reports and submit a patch that i wrote trying to resolve the problem on my (multiple) wsdl.
 
Thanks
Rémy Bertrand
 
 

Attachment: test_1_4.wsdl
Description: Binary data

Reply via email to