Wednesday, November 14, 2012

What is new in Java 7 wsimport tool

The Java Platform, Standard Edition version 7.0 includes JAX-WS RI 2.2.The wsimport tool is available in the $JDK/bin folder.

Overview


Java 7 supports Java API for XML Web Services (JAX-WS) 2.2.4 or later, For the top-down development strategy, wsimport is used to generate JAX-WS portable artifacts to support the JAXWS application, which are used for invoking a web service from a web service client, Following Figure shows a graphic view of how wsimport fits into the process and the components it generates.
These artifacts can be packaged in a WAR file with the WSDL and schema documentsalong with the endpoint implementation to be deployed. Also provides wsimport   ant task, see Wsimport ant task and JAX-WS Maven Plug-in, see wsimport mavenplug-in
 Java 6 wsimport tool problem and limitation
    The problem with Java 6 wsimportis that the JAX-WS runtime needs to fetch the wsdls from the endpoint each time a service instance is created, which could incur a network overhead. The wsdls location is saved in the generated artifacts so that the JAX-WS runtime fetches the metadata and service. JAX-WS runtime may have access to local wsdls using various methods such as a Service API, a jax-ws-catalog.xmlfile, or making the wsdl available at a relative local location and using the –wsdlLocation option when running the wsimport tool.The Ability of reading metadata at runtime is useful when there is something made change in the endpoint policy or the service definition and there is no need to regenerate the clients. But it requires an additional connection to access the metadata each time when a service instance is created which can network overhead and costly at times.  In the absence of the runtime fetch of the metadata, the clients would need to be regenerated if the endpoint policy or the service definition has changed. But this needs a workaround to overcome a problem, to make wsdl accessible to the clients at runtime using various methods such as a Service API, a jax-ws-catalog.xmlfile. But, it’s painful to fetches the wsdls and schema associated with the service and generate jax-ws catalog to use the local files

So what is new in Java 7 wsimport tool?
Java 7 support the JAX-WS 2.2.4, which has introduced a new (since JAX-WS RI 2.2.2) -clientjar option of wsimport tool, which automatically downloads the wsdls and schemas and packages all the generated client-side artifacts into a jar file, so just by including the generate jar file by this new option in the classpath, there is no need to fetch the wsdls from the end point each time a service instance is created, thus saving on network overhead.

 –clientjar as shown in the following sample command:

  wsimport -clientjar wsclient.jar http://localhost:8080/ws/hello?WSDL

Summary: The JAXWS runtime involve the running wsimport utility which requires the wsdl to generate all necessary portable artifacts to support and invoke the JAXWS application, additionally by adding the new –clientjar option in wsimport of Java 7 to packages all the generated artifacts into a specified jar. It should also fetch all the wsdls so that there is no need to fetch wsdls from endpoint each time a service instance is created, thus saving on network overhead.

2 comments: