• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Wanted: Simple ant script to demo wsgen and wsimport.

 
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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

http://www.netbeans.org/kb/50/jaxws20.html
reply
    Bookmark Topic Watch Topic
  • New Topic