Written by nitinpai on August 19th, 2007
Working With JAX-WS in JDK 1.6
I had created a web service client from an online web service while learning it for the first time and then had written a tutorial on creating a client with JAX-WS and JAXP. At that time I had JDK 1.5 and JWSDP 2.0 pack for web services.
I tried today working in JDK 1.6 and to my surprise I found out that it comes shipped in with web services utilities which include JAX-WS 2.0, JAXB 2.0, JAXP2.0. This means a lot of ease in the development of web services for the developer. The benefits are:
- There is no need to separately download the JWSDP 2.0 as I had mentioned in my tutorial
- There is no need to remember all the different set of libraries which are required to be included in the classpath before your program has to run.
- It eases out the development and saves your time.
Does that mean there are no Issues?
There are some. The stubs generated in the manner, I had mentioned in the tutorial won’t work if you are working in Java 6. Because I got an error when I had opened the project Eclipse after installing JDK 1.6 which stated,
java.lang.IllegalArgumentException: Expected class javax.xml.bind.annotation.XmlAccessType but found class javax.xml.bind.annotation.AccessType
In order to solve this error you have to generate your stubs once again with the same command i.e wsimport but in this case you should not use the wsimport.bat which comes in JWSDP 2.0. On the contrary you have to use wsimport.exe which is found in <JAVA_HOME>/bin where JAVA_HOME is the installation directory for JDK 1.6. For example in my case it was,
You have to remember that JAX-WS which gets shipped with JDK 1.6 is of version 2.0. The latest offering is however JAX-WS 2.1.2 which is a part of Project Metro for GlassFish. I tried working in JAX-WS 2.1.2 but currently I think there are a lot of compatibility issues in the latest version with JDK 1.6 because I was not able to create the client in 2.1.2 in the same manner.
But I am happy to see my JDK 1.6 making my work easier. Hope to see more such nice features in the future.