WsImport ant task and JDK 6

Travis picture Travis · Jul 28, 2011 · Viewed 19.8k times · Source

I am trying to use jax-ws to generate web service proxy classes, using the wsimport ant task, similarly to this question, with the following follow-on question:

As I understand it, more recent versions of JDK 1.6 include jax-ws and the WsImport ant task is defined in the JDK's tools.jar file.

Why does ant not find this automatically?

Why does eclipse not find this automatically as well?

I found a few references to using jax-ws with JDK 6, but these seem to be based on copying a separately downloaded jax-ws library and dropping it into the JDK ext folder (which I assume is no longer required given that it is actually bundled with the JDK now).

What is the proper way to use the wsimport task with a version of JDK 1.6 that already includes jax-ws?

My build XML:

<?xml version="1.0" encoding="UTF-8"?>
<project name="wsproxy">
    <taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport" />
    <target name="wsgentest">
        <wsimport
            wsdl="http://localhost/Service?wsdl"
            destdir="bin-gen"
            sourcedestdir="src-gen"
            keep="true"
            verbose="true"
            package="com.ws">
        </wsimport>
    </target>
</project>

Answer

Travis picture Travis · Aug 3, 2011

It turns out the WsImport class that is in the JDK is not actually an ant task, but the actual wsimport command line tool. I misread the package name as well: com.sun.tools.internal.ws.

The actual ant task is available in webservices-tools.jar in the metro package here. You will need to drop it in the ant lib directory.