You can customize the translation to and from Java types with a bindings file. For example, if you wanted to have all xsd:int elements bound to BigInteger, create a file bindings.xjb with the content
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:globalBindings>
<!-- use BigInteger instead of int-->
<jxb:javaType name="java.math.BigInteger" xmlType="xs:int"/>
</jxb:globalBindings>
</jxb:bindings>
When you call wsdl2java, use the -b
option to specify the bindings file
wsdl2java -b bindings.xjb foo.wsdl
This will cause XJC to generate an adapter class, probably named something like
org.w3._2001.xmlschema.Adapter1
Your generated objects will make use of this class with the @XmlJavaTypeAdapter anotation.
You can also provide your own adapter methods using the parseMethod
and printMethod
attributes of <jxb:javaType />
.
The Customizing JAXB Bindings section of the Java Web Services Tutorial provides more detail on what you can do with <jxb:javaType />
.