Posted by ramapulavarthi
on August 18, 2008 at 5:14 PM PDT
JAX-WS relies on JAXB for data binding. When you invoke Wsimport Tool on a wsdl, It in-turn calls XJC tool in JAXB RI to generate the beans used by the JAX-WS runtime. Occasionally, You may need to pass XJC specific command line options through wsimport tool to customize the databinding. This blog explains how one can pass such options through wsimport.
JAX-WS relies on JAXB for data binding. When you invoke Wsimport Tool on a wsdl, It in-turn calls XJC tool in JAXB RI to generate the beans used by the JAX-WS runtime. Occasionally, You may need to pass XJC specific command line options through wsimport tool to customize the databinding. You can do it easily with Wsimport. This feature has been there from JAX-WS 2.1 and hopefully this blog explains the common questions on its usage.
If you are using XJC directly, you could pass those options on the command-line for XJC tool or as nested elements incase of XJC ant task .
For example, if you want to disable the strict schema correctness checking while compiling the schema.
You can use
/path/to/jaxb/bin/xjc.sh -nv myschema.xsd
or in ant like
<xjc schema="src/myschema.xsd" destdir="src">
<arg value="-nv" />
More about XJC command-line options can be found here
But, if you want to customize the XJC behavior using wsimport tool, you can use on of the following method.
For the command-line wsimport tool, you can pass xjc options using -B prefix. For passing the similar xjc option as described above, you can use
/path/to/jaxws/bin/wsimport.sh -B-nv myservice.wsdl
Notice that XJC options are differentiated from wsimport options by prepending "-B" to the option.
The same through wsimport ant task can be done using the nested element which follows the same command-line argument mechanism in Ant .
This mechanism can also be useful for using XJC plugins through wsimport as explained in Kohsuke's blog . Similarly, you can pass episode files created through previous jaxb compilation to Wsimport ant task using the nested element.