aspose file tools
The moose likes EJB and other Java EE Technologies and the fly likes Eclipse 3.3, Glassfish, WebServices and wsimport Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Eclipse 3.3, Glassfish, WebServices and wsimport" Watch "Eclipse 3.3, Glassfish, WebServices and wsimport" New topic

Eclipse 3.3, Glassfish, WebServices and wsimport

Stephanie Hehreuer

Joined: Jul 22, 2007
Posts: 4
These are a beginner's dumb questions. More about eclipse than Glassfish, perhaps.

I'm using eclipse 3.3 with Glassfish on Mac OS X. I'm attempting to build a toy "Hello World" level web service example, both the service and a client to connect to it.

Deploying the web service to Glassfish, from within eclipse, was easy: "Run As -> Run on server". Bingo; code compiled, web service deployed and running.

The client side is what I'm struggling to do from within eclipse, and maybe there isn't a way to do that? The examples I've encountered online for this all seem to, in a shell, manually invoke the wsimport script to generate the client-side stub classes from the web service's WSDL file. Is there a way to perform this step from within eclipse? Or is it not integrated into the JavaEE perspective, and you really must drop outside eclipse to do it?

And if that's true, I can't quite figure out how to generate the stubs into a place in the client project in eclipse, in a way that eclipse can see and use those classes in the client code. I know I need to modify the client project's build path. Is there a canonical way people do this -- I mean, do they generate the stub classes in <client-project>/build/classes? (I can't seem to make eclipse be happy about a path beneath there...) Surely you don't generate the stub classes into the web service project?? Or do I plop them into the client project in (say) <client-project>/wsimports (i.e., a new directory not below the "build" directory that eclipse makes)?

Told you they were dumb questions. :-) Thanks in advance, --SR
purushottaman dwarkanathan

Joined: Apr 26, 2005
Posts: 25
I had done a sample web service project in eclipse europa with the glassfish server integrated. This program invokes a web service via Java

Since it is using the new spec JAX-WS and not the AXIS java2WSDL and WSDL2Java conversion, the implementation is slightly different.

Since, it seems that you have been able to deploy and run the project, your main concern was about generating the artifacts from the eclipse.

Here are a few suggestions, which will assist you...

You need to write a build file. Open it from the ant view in eclipse .

goto menu window ---> show view --other --ANT

Run the tasks and the wsimport and wsgen will run and place the files in the respective folders.

I am pasting a sample build file, you can modify that according to your needs

My src directory name is fromjava.

This is how my deploy-targets.xml looks like

<property environment="env"/>

<property name="as.home" value="${env.AS_HOME}"/>
<property name="lib.home" value="${env.JAXWS_HOME}/lib"/>
<property name="lib.sample.home" value="${basedir}/../lib"/>
<property name="build.home" value="${basedir}/build"/>
<property name="build.war.home" value="${build.home}/war"/>
<property name="build.classes.home" value="${build.home}/classes"/>

<property name="domain" value="domain1"/>

<target name="deploy" depends="deploy-tomcat, deploy-appserver"/>

<target name="deploy-appserver" unless="tomcat">
<copy file="${build.war.home}/jaxws-${}.war"

<target name="deploy-tomcat" if="tomcat">
<copy file="${build.war.home}/jaxws-${}.war"

THis is the build.xml file

<?xml version="1.0" encoding="UTF-8"?>

<project basedir="." default="help" name="fromjava">

<import file="etc/deploy-targets.xml"/>

<path id="jaxws.classpath">
<pathelement location="${java.home}/../lib/tools.jar"/>
<pathelement location="${lib.sample.home}/jaxwsSampleUtils.jar"/>
<fileset dir="${lib.home}">
<include name="*.jar"/>
<exclude name="j2ee.jar"/>

<taskdef name="apt" classname="">
<classpath refid="jaxws.classpath"/>

<taskdef name="wsimport" classname="">
<classpath refid="jaxws.classpath"/>

<target name="setup">
<mkdir dir="${build.home}"/>
<mkdir dir="${build.classes.home}"/>
<mkdir dir="${build.war.home}"/>

<target name="build-server-java" depends="setup">
<path refid="jaxws.classpath"/>
<pathelement location="${basedir}/src"/>
<option key="r" value="${build.home}"/>
<source dir="${basedir}/src">
<include name="**/server/*.java"/>
<include name="**/common/*.java"/>
<!-- copy handlers descriptor file -->
<copy todir="${build.classes.home}">
<fileset dir="${basedir}/src">
<include name="**/server/**/*.xml"/>

<target name="clean">
<delete dir="${build.home}" includeEmptyDirs="true"/>

<target name="create-war">
<war warfile="${build.war.home}/jaxws-${}.war" webxml="etc/web.xml">
<webinf dir="${basedir}/etc" includes="sun-jaxws.xml"/>
includes="*.wsdl, *.xsd"
<classes dir="${build.classes.home}"/>

<target name="generate-client" depends="setup">

<target name="client" depends="generate-client">
<classpath refid="jaxws.classpath"/>

<target name="run">
<java fork="true" classname="fromjava.client.AddNumbersClient">
<path refid="jaxws.classpath"/>
<pathelement location="${build.classes.home}"/>
<pathelement location="${basedir}/etc"/>

<target name="help">
<echo message="server: Builds and deploy the service endpoint WAR"/>
<echo message="client: Builds the client"/>
<echo message="run: Runs the client"/>
<echo message="server-j2se: Builds and deploy the Endpoint API based service"/>
<echo message="server-j2se-stop: Stops Endpoint API based service"/>


<target name="server" depends="setup">

<antcall target="clean"/>

<antcall target="build-server-java"/>

<antcall target="create-war"/>

<antcall target="deploy"/>

<target name="server-j2se" depends="setup">
<antcall target="clean"/>

<antcall target="build-server-java"/>

<echo message="Starting endpoint... To stop: ant server-j2se-stop "/>

<java fork="true" classname="fromjava.server.AddWebservice">
<path refid="jaxws.classpath"/>
<pathelement location="${build.classes.home}"/>

<target name="server-j2se-stop" depends="setup">
<get src="http://localhost:9090/stop" dest="stop.status"/>


You also need to have the following files

This is the sun-jaxws.xml

<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns='' version='2.0'>

This is the web.xml file

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns=""
<description>JAX-WS endpoint - fromjava</description>

IBM Certified SOA Associate
I agree. Here's the link:
subject: Eclipse 3.3, Glassfish, WebServices and wsimport