wsimport is the tool that fits the bill, JDK 1.6 comes with it. Instead of running it at the command line. I want to integrate wsimport into eclipse and run it as a task. After some digging, following steps seemed working for me. Good thing is that the vendor supplied some basic Java WS jars. For what I want to do, I had no intention to separate which ones are actually used by wsimport and which ones are not. I think all of them can be obtained from Java WSDP 2.0 download, less some XML parsing jars, are used directly or indirectly by web serice. From my init tests, it showed that jaxws-* and maybe a few others were absolutly needed, without them, we would see class not found exception. So here is the list:
activation.jar
FastInfoset.jar
http.jar
jaxb-api.jar
jaxb-impl.jar
jaxb-xjc.jar
jaxws-api.jar
jaxws-rt.jar
jaxws-tools.jar
jsr173_api.jar
jsr181-api.jar
jsr250-api.jar
mimepull.jar
resolver.jar
saaj-api.jar
saaj-impl.jar
stax-ex.jar
streambuffer.jar
woodstox.jar
Step 1: Define class path in build.xml
I have all the jars (including above jars) related this project in a CommonLib directory.
<path id="compile.class.path">
<fileset dir="../CommonLib" includes="**/*.jar"/>
<pathelement path="${build}/classes"/>
</path>
Step 2: Add taskdef for wsimport and refer to above classpath
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">Step 3: add a target to execute wsimport
<classpath refid="compile.class.path" />
</taskdef>
Attributes of wsimport tag can be different depending on the needs
<target name="wsimport">
<wsimport
wsdl="myTest.wsdl"
wsdllocation="http://localhost:8080/myservice/test?wsdl"
destdir="c:/temp/ws/proxy"
sourcedestdir="c:/temp/ws/src"
keep="true"
debug="true"/>
</target>