Default Behavior
In JAX-WS reference implementation, ‘wsimport’ defaults to wrapper doc/lit style when generating Java classes from WSDL. In doing so, the generated ‘PortType’ interface class sometimes uses ‘javax.xml.ws.Holder
public void startOperation( XMLGregorianCalendar eventTime, OpConfigs opConfigs, Location location, Holder<String> status, Holder<String> description) { // TODO Auto-generated method stub return null; } }
Disable Wrapper Style
You can use a custom binding file to disable the default wrapper style as follows if you need to.
* Create a custom binding file, e.g. CustomBinding.xml.
<bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" wsdlLocation="OperationService.wsdl" xmlns="http://java.sun.com/xml/ns/jaxws"> <!-- Disable default wrapper style --> <enableWrapperStyle>false</enableWrapperStyle> </bindings>
* Including ‘binding’ element in ‘wsimport’ Ant task.
<wsimport debug="true" verbose="${verbose}" keep="true" destdir="${generated.dir}" package="${src.pkg.name}.server" wsdl="${wsdl.file}"> <binding dir="${basedir}/etc" includes="CustomBinding.xml"/> </wsimport>
After setting ‘enableWrapperStyle’ to false, the same generated operation name in PortType class becomes:
public Response startOperation(TStartOperation parameters) { // TODO Auto-generated method stub return null; }
For Simpler and Better Typed Binding
* Create a new JAXB binding file, e.g. simple.xjb:
<?xml version="1.0" encoding="UTF-8"?> <!-- This enables the simple binding mode in JAXB. See http://weblogs.java.net/blog/kohsuke/archive/2006/03/simple_and_bett.html --> <jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0" xmlns:xjc= "http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc"> <jaxb:globalBindings> <xjc:simple /> </jaxb:globalBindings> </jaxb:bindings>
* Specify in wsimport Ant task:
<wsimport debug="true" verbose="${verbose}" keep="true" destdir="${generated.dir}" package="${src.pkg.name}.server" wsdl="${wsdl.file}"> <binding dir="${basedir}/etc" includes="CustomBinding.xml,simple.xjb"/> </wsimport>
* The operation now looks like this:
public Response startOperation(StartOperation parameters) { // TODO Auto-generated method stub return null; }
Parameter name ‘StartOperation’ is more readable now among benefits.
References
* jaxws-ri/docs/customizations.html
* Wrapper Style
* Customizing XML Schema binding