I use the following Ant task to create client code for the web service endpoint:
<wsimport wsdl="target/classes/META-INF/wsdl/MyService.wsdl" sourcedestdir="target/wsimport" verbose="true" xnocompile="false" xendorsed="true" destdir="target/classes" keep="true" package="com.example.client.jaxws" wsdlLocation="/META-INF/wsdl/MyService.wsdl" />
This generates classes that clients use to transfer data to the web service, for example
class Foo { String name; List<String> bars; public void setName(String name) { this.name = name; } public String getName() { return name; } public List<String> getBars() { return bars; } }
Note that for the bars property, the generated class does not include setter, so the client will need to access it through:
someFoo.getBars().add("val");
However, the lack of a setter means that this class will not work with various tools that rely on the JavaBeans convention (e.g. Dozer), so I would like to force wsimport to generate setters. I found a thread that indicates that you can force the setter to be generated by adding the following to the Ant task
<xjcarg value="-Xcollection-setter-injector"/>
However, this thread is quite old, and the above seems to no longer work.
source share