Engineering Full Stack Apps with Java and JavaScript
The jax-ws tools wsgen and wsimport generate artifacts for easy for web service development, deployment, and invocation.
Previously with JAX-RPC, frameworks like axis 1 had tools like wsdl1java and java2wsdl, but we should consider only jax-ws tools now.
If we were using simple types, it would not make much difference if we create Publisher and Client using the wsgen and wsimport generated artifacts; however these tools become more useful when we are using complex types and collections in our applications, as parameters and return types.
The wsimport tool reads a WSDL and generates all the required artifacts for web service development, deployment, and invocation.
The wsimport tool supports the top-down approach to developing JAX-WS Web services, where you are starting from a wsdl.
The wsimport tool generated JAX-WS portable artifacts include
Service Endpoint Interface (SEI),
Service, Exception class mapped from wsdl:fault (if any),
JAXB generated value types (mapped java classes from schema types) etc.
These artifacts can be packaged in a WAR file with the WSDL and schema documents along with the endpoint implementation to be deployed.
The wsimport tool can be launched using the command line script wsimport.sh (Unix) or wsimport.bat (windows).
The wsgen tool reads an existing web service implementation class (SIB) and generates the required JAX–WS portable artifacts for web service development and deployment.
The wsgen tool can be used for bottoms-up approach, where you are starting from a service endpoint implementation (SIB) rather than a wsdl.
From JAX-WS RI 2.1.4 onwards, you don't have to run wsgen, the runtime takes care of it by generating all required classes dynamically.
I am using java 7 which has that version and hence it will generate all classes dynamically when I run the publisher.
Even the latest java 6 version (update 37) too has the required version and I generated the classes on the fly.
However compared to java 7, java 6 gave a INFO message that these classes were dynamically created.
The wsgen tool can be launched using the command line script wsgen.sh (Unix) or wsgen.bat (windows).
JAX-WS RI now also provides wsimport and wsgen ant tasks.
The wsimport and wsgen tools are part of core java 6 and above.
If you want to use a newer version of JAX-WS than that is part of the java version you have, you can work around by using the endorsed standards override mechanism.
For this, you can copy just two jars jaxws-api.jar and jaxb-api.jar into the JRE endorsed directory, which is $JAVA_HOME/lib/endorsed.
The directory might not exist yet and in that case you will have to create it yourself.
Some application servers or containers might modify the location of the endorsed directory to a different place.
From inside the code, you can check the current location by doing System.out.println(System.getProperty("java.endorsed.dirs"));
An endorsed standard is a standards process other than the Java Community Process.
It is therefore anticipated that such standards may be revised between releases of Java.
We can use the Endorsed Standards Override Mechanism to provide the newer versions than those included in the Java platform.
If you want to use a newer version of JAX-WS than that is part of the java version you have, you can work around by using the endorsed standards override mechanism.