Java 7 supports Java API for XML Web Services (JAX-WS) 2.2.4 or later. In this chapter, we shall discuss the procedure for using the new -clientjar
option in the wsimport
task/tool in Java 7. We require a Java IDE that supports Java 7 and a web container that also supports Java 7. We need to install the following JDK and software as discussed in the previous chapter:
The sample NetBeans project is available in the downloadable sample ZIP file. This chapter has the following sections:
build
file wsimport
tool from the command lineThe wsimport
tool or the wsimport
Ant task is used to generate JAX-WS portable artifacts, which are used for invoking a web service from a web service client, from a service Web Services Description Language (WSDL). Specifically, wsimport
generates the following artifacts:
The problem with Java 6 wsimport
is 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 WSDL location is saved in the generated artifacts and the JAX-WS runtime fetches the metadata, which is useful if the endpoint policy or the service definition has changed. 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 have changed. JAX-WS runtime may have access to local WSDLs using various methods such as a Service API, a jax-ws-catalog.xml
file, or making the WSDL available at a relative local location and using the -wsdlLocation
option when running the wsimport
tool.