JAX-WS RI web services deployment made simplified.
With JAX-WS 2.2.2 RI /Metro 2.1, Web Services deployment using RI deployment model has been made even simpler by making the web services configuration in web.xml optional.
As you know, JAX-WS RI supports two deployment models to publish web services, one using JSR-109 deployment model and the other JAX-WS RI specific deployment model. In JSR-109 deployment model, a web service can be specified in web.xml as a servlet class and any additional configuration is specified in webservices.xml. JSR-109 supported container would then publish the web service using the servlet framework. With Java EE5, configuration of web.xml is made optional with the use of annotations. Though this is made quite simple, it works only on Java EE Containers supporting JSR-109. To support web service deployment on plain servlet container like Tomcat, We use JAX-WS RI deployment model, where web service configuration is specified in sun-jaxws.xml and explicit declaration of RI specific servlet classes in web.xml. So, to deploy JAX-WS web services on a Servlet 2.4 Container, one has to at the minimal configure web.xml and sun-jaxws.xml. Here is sample web.xml configuration for JAX-WS web service.
Old configurtation in web.xml:
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
<description>JAX-WS endpoint - fromwsdl</description>
Most of the time such configuration is auto-generated by IDEs like Netbeans and is unnecessary. With the introduction of dynamic registration of Servlets feature in Servlet 3.0, this whole thing can be made optional. With JAX-WS 2.2.2 RI, JAX-WS Runtime utilizes the Servlet 3.0 capabilities to dynamically register a servlet for each web service endpoint specified in sun-jaxws.xml. This should work in any Servlet 3.0 container like GlassFish V3, Tomcat 7 etc. This simplified deployment feature is introduced in GlassFish 3.1 MS3 and you can find a working sample from Metro 2.1 latest promoted build here. The dynamically registered JAX-WS servlet uses default settings in most cases and if you need to do advanced configuration like security, you can still specify in web.xml as you used to earlier.
Of course, with the use of jax-ws annotations, even configuration sun-jaxws.xml can be made optional making it completely descriptor free, but that requires specifying a default url-pattern like in JSR-109 or custom pattern like in Jersey REST services, in the JAX-WS specification. As it is, such descriptor free deployment is already supported by 109 implementation from Glassfish V2. This definitely is a step towards that goal and one less configuration file to worry about.
You can download the optional_webxml sample from JAX-WS RI 2.2.2 nightly build or Metro 2.2.1 promoted build and let us know your feedback.