The JAX-WS Tools – wsimport and wsgen

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

  1. The wsimport tool reads a WSDL and generates all the required artifacts for web service development, deployment, and invocation.

  2. The wsimport tool supports the top-down approach to developing JAX-WS Web services, where you are starting from a wsdl.

  3. 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.

  4. These artifacts can be packaged in a WAR file with the WSDL and schema documents along with the endpoint implementation to be deployed.

  5. The wsimport tool can be launched using the command line script wsimport.sh (Unix) or wsimport.bat (windows).

 

The wsgen tool

  1. 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.

  2. The wsgen tool can be used for bottoms-up approach, where you are starting from a service endpoint implementation (SIB) rather than a wsdl.

  3. 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.

  4. The wsgen tool can be launched using the command line script wsgen.sh (Unix) or wsgen.bat (windows).

 

Additional Points

  • 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"));

References and notes: 

Endorsed standard process

  • 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.

Quick Notes Finder Tags

Activities (1) advanced java (1) agile (3) App Servers (6) archived notes (2) Arrays (1) Best Practices (12) Best Practices (Design) (3) Best Practices (Java) (7) Best Practices (Java EE) (1) BigData (3) Chars & Encodings (6) coding problems (2) Collections (15) contests (3) Core Java (All) (55) course plan (2) Database (12) Design patterns (8) dev tools (3) downloads (2) eclipse (9) Essentials (1) examples (14) Exception (1) Exceptions (4) Exercise (1) exercises (6) Getting Started (18) Groovy (2) hadoop (4) hibernate (77) hibernate interview questions (6) History (1) Hot book (5) http monitoring (2) Inheritance (4) intellij (1) java 8 notes (4) Java 9 (1) Java Concepts (7) Java Core (9) java ee exercises (1) java ee interview questions (2) Java Elements (16) Java Environment (1) Java Features (4) java interview points (4) java interview questions (4) javajee initiatives (1) javajee thoughts (3) Java Performance (6) Java Programmer 1 (11) Java Programmer 2 (7) Javascript Frameworks (1) Java SE Professional (1) JPA 1 - Module (6) JPA 1 - Modules (1) JSP (1) Legacy Java (1) linked list (3) maven (1) Multithreading (16) NFR (1) No SQL (1) Object Oriented (9) OCPJP (4) OCPWCD (1) OOAD (3) Operators (4) Overloading (2) Overriding (2) Overviews (1) policies (1) programming (1) Quartz Scheduler (1) Quizzes (17) RabbitMQ (1) references (2) restful web service (3) Searching (1) security (10) Servlets (8) Servlets and JSP (31) Site Usage Guidelines (1) Sorting (1) source code management (1) spring (4) spring boot (3) Spring Examples (1) Spring Features (1) spring jpa (1) Stack (1) Streams & IO (3) Strings (11) SW Developer Tools (2) testing (1) troubleshooting (1) user interface (1) vxml (8) web services (1) Web Technologies (1) Web Technology Books (1) youtube (1)