If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Thursday, March 26, 2015

Fixing collisions ObjectFactory while executing wsdl2java

Often you have to deal with WSDL's from third parties. Sometimes the WSDL including referenced schemas are setup crappy and you run into issues while converting the WSDL to Java. Below we will look into how to fix these issues.

Eclipse will complain with following message

[ERROR] file:/playground/objectfactory/src/main/resources/xsd/helloworld.xsd [32,3]: (Relevant to above error) another "ReasonType" is generated from here. [ERROR] file:/playground/objectfactory/src/main/resources/xsd/helloworld.xsd [32,3]: Two declarations cause a collision in the ObjectFactory class. [ERROR] file:/playground/objectfactory/src/main/resources/xsd/helloworld.xsd [26,3]: (Related to above error) This is the other declaration. [ERROR] file:/playground/objectfactory/src/main/resources/xsd/helloworld.xsd [9,3]: Two declarations cause a collision in the ObjectFactory class. [ERROR] file:/playground/objectfactory/src/main/resources/xsd/helloworld.xsd [10,3]: (Related to above error) This is the other declaration. [ERROR] file:/playground/objectfactory/src/main/resources/xsd/helloworld.xsd [15,7]: Two declarations cause a collision in the ObjectFactory class. [ERROR] file:/playground/objectfactory/src/main/resources/xsd/helloworld.xsd [14,7]: (Related to above error) This is the other declaration. A class/interface with the same name "com.pelssers.helloworld.wrapper.ReasonType" is already in use. Use a class customization to resolve this conflict.

Below a version that fixes all issues. Ps. Sometimes it might also be useful to add @underscoreBinding="asCharInWord" to the globalBindings.

No comments:

Post a Comment