Recently I need to create a client application to get web service with SOAP/HTTP. What I have is just WSDL URI.  First I use Eclipse to genearte client program but it only automatically does for Axis 1.4 run time. Then I decide to use JAX-WS 2.0 and WSIT.  I list the steps and you can follow it.

1. Download “webservices-tools.jar”

This is a specific task which is part of WSIT implementation of JAX-WS. Check this out

2. Run Ant to generate stub


<project name=”weatherServiceClient” basedir=”.”>

<property name=”src” value=”src” />

<property name=”build” value=”build” />

<property name=”dist” value=”dist” />

<path id=”jaxws.classpath”>

<pathelement path=”${classpath}”/>

<pathelement location=”lib/webservices-tools.jar”/>


<path id=”build.classpath”>

<pathelement path=”${classpath}”/>

<pathelement path=”${build}”/>


<target name=”generateStub” description=”Generate stub”>

<mkdir dir=”build” />

<mkdir dir=”dist” />

<taskdef name=”wsimport” classname=””>

<classpath refid=”jaxws.classpath”/>













<target name=”compileClient” description=”Compile client source”>

<javac destdir=”${build}” debug=”on” deprecation=”on” optimize=”on” classpathref=”build.classpath”>

<src path=”${src}” />



<target name=”runClient” description=”Run client”>

<java classname=”com.example.WeatherServiceClient” fork=”true”>

<arg value=”New York”/>


<pathelement location=”${build}”/>




<target name=”jarIt”>

<jar jarfile=”${dist}/${}.jar” basedir=”build” />


<target name=”runClientWithJar” description=”Run client with jar”>

<java classname=”com.example.WeatherServiceClient” fork=”true”>


<pathelement location=”${dist}/${}.jar”/>




<target name=”clean” description=”Cleanup”>

<delete dir=”${dist}” />

<delete dir=”${build}” />




c:\Temp\myjaxws-examples>ant generateStub

3. Compile “WeatherServiceClient”


package com.example;

public class WeatherServiceClient {

private static String CITY = “Paris”;

public static void main(String args[]) {

if (args.length>0 && args[0] != null){

CITY = args[0];


WeatherSoap wsp = new Weather().getWeatherSoap();

String forecast = wsp.getWeather(CITY);

System.out.println(CITY + “‘s weather forecast=” + forecast);




c:\Temp\myjaxws-examples>ant compileClient

4. Run “WeatherServiceClient”

c:\Temp\myjaxws-examples>ant runClient

5. jar command

c:\Temp\myjaxws-examples\dist>java -cp .;dis\weahterServiceClient.jar com.example.WeatherServiceClient

6. Structure:












7. Reference:

Web Services Made Easy with JAX-WS 2.0

Create JAX-WS Service in 5 Minutes (Tutorial)

Doc: wsimport

Java Tools for the JSON Format