Get rid of JAXBElement in classes generated by wsimport called from ant

You will have to customize the binding.


The reason for using JAXBElement wrappers in the generated beans is probably, that the WSDL declares the field to be both optional and nillable. To distinguish between "not present" and "present, but null", the String type cannot be used directly, since the String in both cases would be null.

If you don't need to distinguish between the two situations, you can configure the code generator to use the String type instead. I'm not 100% sure how to do this with the ant task, but you'll probably find the relevant information in the ant task documentation.


I have faced similar problem.

I have used below binding XML while ceiling wsimport :with reference of this link.

Binding file

<jaxb:bindings version="2.1" 
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" 
xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
   <jaxb:globalBindings generateElementProperty="false"/> 
</jaxb:bindings>

Sample wsimport command:

wsimport -keep  <WSDL_location>  -b employerServiceWSD
L_binding.xjb

Note : employerServiceWSDL_binding.xjb contain of above binding xml entry.

Hope it will work for other also.