This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Services and the fly likes Wanted: Simple ant script to demo wsgen and wsimport. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Wanted: Simple ant script to demo wsgen and wsimport." Watch "Wanted: Simple ant script to demo wsgen and wsimport." New topic
Author

Wanted: Simple ant script to demo wsgen and wsimport.

Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 381
Does someone have a simple ant script that demonstrates how to run wsgen and wsimport?

I'm running wsgen, running my little web service in the background and running wsimport from the command line.

I see wsimport creating some class files but I'm not sure what to do next. I want to use eclipse to create a client for this soap service. How do I do that using ant and eclipse?

Thanks,
Siegfried

Here is my java6 web service:
Preeti Arora
Ranch Hand

Joined: Jan 26, 2007
Posts: 74
Hi,

I m posting you simple build file for wsimport& wsgen.




<target name="-pre-dist">
<taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen">
<classpath path="${javac.classpath}"/>
</taskdef>
<wsgen
debug="true"
keep="true"
destdir="build/web/WEB-INF/classes"
resourcedestdir="build/web/WEB-INF/classes"
sei="my.sample.server.ServiceImpl">
<classpath>
<pathelement path="${javac.classpath}"/>
<pathelement location="${java.home}/../lib/tools.jar"/>
<pathelement location="build/web/WEB-INF/classes"/>
</classpath>
</wsgen>
</target>
<!-- Overrides build-impl.xml target to start server and generate client artifacts before building test. -->
<target name="-pre-compile-test">
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
<classpath path="${javac.classpath}"/>
</taskdef>
<!-- Use "debug" or "run" here. -->
<antcall target="run"/>
<echo>running wsimport</echo>
<wsimport
debug="true"
keep="true"
destdir="test"
package="my.sample.test.generated"
wsdl="http://localhost:8080/JAX-WS20Project/hello?wsdl"/>
</target>



Cheers,
Preeti
Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 381
Thanks!

I have a few more questions:
(1) Can you explain your choice of task names that begin with a "-"? I removed the "-" from them so I could specify them from the command line.

(2) After running wsimport, what do I do? How does wsimport help me create a client?

(3) How do I run that ant script? Below is my attempt. Do I have to specify a classpath?

Thanks,
Siegfried
bash-3.2$ ant -f build2.xml pre-compile-test
Buildfile: build2.xml

pre-compile-test:

BUILD FAILED
C:\Documents and Settings\Administrator\java6\ScriptEngineHello\build2.xml:20: t
askdef class com.sun.tools.ws.ant.WsImport cannot be found

Total time: 0 seconds
bash-3.2$ echo $JAVA_HOME
c:\Program Files\Java\jdk1.6.0
Preeti Arora
Ranch Hand

Joined: Jan 26, 2007
Posts: 74
Hi,

I have used netbeans IDE so the-pre specifies that before the war file is made this target should be called.
You can use following targets:

-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile:called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-dist: called before jar building
-post-dist: called after jar building
-post-clean: called after cleaning build products

Also if you are facing class not found then either in your web application add following jar in lib directory or declare classpath variabale in ant script with absolute path to following jar:
activation.jar
fastInfoset.jar
http.jar
jaxv-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
package-rename-task.jar
resolver.jar
saaj-api.jar
saaj-impl.jar
sjsxp.jar

I guess you can download jwsdp-2.0 where youwill get all jar files.

I would say download netbeans IDE since you can make any webservice independant of application server in it.And then can modify ant script and run it from netbeans itself.
I find it very handy.
Bye.
Preeti Arora
Ranch Hand

Joined: Jan 26, 2007
Posts: 74
Hi,

If you choose to download netbeans then simply follow this tutrial:

http://www.netbeans.org/kb/50/jaxws20.html
 
wood burning stoves
 
subject: Wanted: Simple ant script to demo wsgen and wsimport.
 
Similar Threads
Error while deploying the war file using command "asant deploy"
Issue while deploying web service jwstutorial example CLI171
Java EE 5 Tutorial - Problem with Web Services
@WebMethod not found
JAX-WS - please help convert proxy to BindingProvider for HTTP auth