Where to use wsgen?

It doesn't seem where (which directory is the source or classes) it is correct to use wsgen for my WebService class ...

Create a sample document based on the letters WebService:

package hello; import javax.jws.WebService; @WebService public class HelloWorld { public void sayHello() { System.out.println("Welcome to JAX-WS 2!"); } } 

Created the publisher as follows:

 package hello; import javax.xml.ws.Endpoint; public class Publisher { public static void main(String[] args) { Endpoint.publish("http://localhost:8080/jaxws/hello", new HelloWorld()); } } 

Using Eclipse Helios, I automatically create both of these files as * .classes under the appropriate class directory.

So, from the file system, my project looks like this:

 /code/jws_sample | src | hello | HelloWorld.java Publisher.java | classes | HelloWorld.class Publisher.class 

In which directory would I run wsgen?

When I tried it inside:

/ code / jaxws_sample / src / wsgen -cp. hello.HelloWorld

Received:

  Class not found: "hello.HelloWorld" Usage: WSGEN [options] <SEI> where [options] include: -classpath <path> specify where to find input class files -cp <path> same as -classpath &lt;path&gt; -d <directory> specify where to place generated output files -extension allow vendor extensions - functionality not specified by the specification. Use of extensions may result in applications that are not portable or may not interoperate with other implementations -help display help -keep keep generated files -r <directory> resource destination directory, specify where to place resouce files such as WSDLs -s <directory> specify where to place generated source files -verbose output messages about what the compiler is doing -version print version information -wsdl[:protocol] generate a WSDL file. The protocol is optional. Valid protocols are [soap1.1, Xsoap1.2], the default is soap1.1. The non stanadard protocols [Xsoap1.2] can only be used in conjunction with the -extension option. -servicename <name> specify the Service name to use in the generated WSDL Used in conjunction with the -wsdl option. -portname <name> specify the Port name to use in the generated WSDL Used in conjunction with the -wsdl option. Examples: wsgen -cp . example.Stock wsgen -cp . example.Stock -wsdl -servicename {http://mynamespace}MyService 

This actually shows me the WSDL in the browser, and also when I tried to issue the wsgen command from $ MyProject / classes, it actually created the jaxws folder with the SayHelloResponse.class files, but not the SayHelloResponse.java files?

Thanks for taking the time to read this.

+7
source share
7 answers

It looks like you need to compile the files into class files first and then pass them to wsgen.

 classpath <path> specify where to find input **class files** 

I could be wrong, but I believe that I had to do the same in the past.

Thanks,

Jeffrey Kevin Pry

+7
source

You need to include "-keep" and you can specify "-s / path / to / src" to save the generated JAXWS files. Since these are generated files, best practice usually helps you not to store files and create them just for packaging. The disadvantage of storing files and possibly editing them is that if you restore files, your changes may be lost.

For example, I have a JAX-WS endpoint that is defined in a Maven project, and the WSGEN target is called every time a service is packaged.

+1
source

you need to run wsgen against the sei class file, not the source file. cd from the src directory and to the class directory and wsgen vs HelloWorld.class

+1
source

A bit late answer, but I can help others. I use this script to generate WSDL and XSD if necessary (Windows only). It can be easily prepared for Linux and Mac. I am using the Glassfish appserver application library. You can replace these libraries with your application server or a bare library.

 @echo off set WSGEN="C:\Java\jdk1.6.0_39\bin\wsgen.exe" set J1="C:\Java\jdk1.6.0_39\lib\tools.jar" set J2="C:\Java\glassfish-3.1.2.2\glassfish\modules\webservices-osgi.jar" set J3="C:\Java\glassfish-3.1.2.2\glassfish\modules\endorsed\webservices-api-osgi.jar" set J4="C:\Java\glassfish-3.1.2.2\glassfish\modules\jaxb-osgi.jar" set J5="C:\Java\glassfish-3.1.2.2\glassfish\modules\endorsed\jaxb-api-osgi.jar" set J6="C:\Java\glassfish-3.1.2.2\glassfish\modules\javax.ejb.jar" set J7="D:\NetBeansProjects\OTP\target\OTP-1.0\WEB-INF\lib\commons-lang3-3.1.jar" set J8="D:\NetBeansProjects\OTP\target\OTP-1.0\WEB-INF\lib\commons-codec-1.8.jar" set OUTPUT_DIR="D:\NetBeansProjects\OTP" @echo on %WSGEN% -classpath %J1%;%OUTPUT_DIR%\target\classes;%J2%;%J3%;%J4%;%J5%;%J6%;%J7%;%J8%; -d %OUTPUT_DIR%\jax-ws -Xendorsed -keep -wsdl -r %OUTPUT_DIR%\jax-ws -s %OUTPUT_DIR%\jax-ws -verbose com.avalant.ws.GenerateOTPWS 
+1
source

First you need to create the "jaxws" directory in your "hello" directory.

Then try running this command from the directory "/ code / jws_sample":

 wsgen -keep -cp classes/ -s src/ HelloWorld 

The -s command tells the generator where to place the source files.

This was created using a script that I use here at work and could not verify this before submitting. However, hopefully this will give you some direction.

0
source

It is strange that your created class files are not in / classes / hello /, as your package says ...

Well, considering that your IS class files are in /classes/hello/HelloWorld.class, as it should be, all you have to do from your class folder is :

wsgen -keep -cp. -d. -s ../ src hello.HelloWorld

Just tested and works great for me. Remebember, calling CMD from your classes folder .

0
source

This is a very late answer, but for others:

 wsgen -verbose -keep -cp <folder with .class files> hello.HelloWorld -s <folder where u want the generated artifacts> 

The -verbose option should show logs. <> The -cp option is found if your current working directory does not match the .class file. -s is for source files. The -keep option should contain the generated files.

0
source

All Articles