Thursday, August 26, 2010

In the previous post I've written about Apache CXF and JBossWS-CXF implementation of JAXWS 2.2 HTTP SPI. From a container point of view, a bit of additional coding is required for making an existing http server compliant too.

Similarly to what Jitendra Kotamraju did for Grizzly, I've just created a small project for using the JDK6 httpserver with this HTTP SPI, basically allowing any JAXWS 2.2 stack implementation to be used on top of it (not just the JAXWS RI as mentioned here). The project only runtime dependency is the JAXWS 2.2 API, so it's completely vendor agnostic (the project testsuite uses Apache CXF just for the sake of testing with a JAXWS 2.2 impl).So, the following is now possible using any JAXWS 2.2 compliant implementation:import com.sun.net.httpserver.HttpServer;import javax.xml.ws.spi.http.HttpContext;import org.jboss.ws.httpserver_httpspi.HttpServerContextFactory;..

JAXWS 2.2 specification introduced a compact HTTP SPI; that defines the minimal set of required information a http server container and a JAXWS stack implementation need to share for allowing an endpoint deployment and invocation.

.. as well as a Endpoint publish(Object obj) method for allowing the JAXWS RI (only) to deploy an endpoint on top of JDK6 httpserver. However, this was not portable and different JAXWS implementation could actually support different and vendor specific http context implementations passed in that object instance in publish(Object obj). For instance, Apache CXF - despite being JAXWS 2.1 compliant - didn't have a specific implementation for the publish(Object obj) method, but just of the publish(String s) one.

With JAXWS 2.2 the specification added a Endpoint publish(HttpContext ctx) method and the other classes/interfaces defining the HTTP SPI together with the HttpContext. A JAXWS 2.2 implementation is supposed to be able to deploy an endpoint on top of any http container that also supports the JAXWS 2.2 HTTP SPI.

Thanks to a joint work of Daniel Kulp and me, the current trunk for Apache CXF now supports this JAXWS 2.2 HTTP SPI. This means you'll soon be able to perform a quick deployment and test of your endpoint using Apache CXF (or JBossWS-CXF, of course ;-)) on top of the JAXWS 2.2 compatible http server you prefer.

As a proof of that, I've added a testcase leveraging Jitendra Kotamraju's Grizzly transport bridge project for deploying on top of Grizzly http server, while still having the whole ws invocation being handled by CXF:import javax.xml.ws.spi.http.HttpContext;import com.sun.grizzly.http.embed.GrizzlyWebServer;import org.jvnet.jax_ws_commons.transport.grizzly_httpspi.GrizzlyHttpContextFactory;