Question

JAX-WS implementation bundled with JDK6 can be used to provide a web services server without any additional libraries. JVM will start with a WS server on a specified port.

http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2/

http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2_pt2/

The question I have is how does this differ from project Metro? If the end goal is to host web services inside tomcat, then can I still use bundled functionality and then just redirect to this bundled ws server or is it better to deploy the metro servlet?

Was it helpful?

Solution

As far as I know JAX-WS is only a template which has to be implemented by either the JDK6 or the Metro implementation.

Metro just is the standard implementation shipped with the Glassfish Application Server. See here.

Therefore there shouldn't be any differences.

OTHER TIPS

Well, The first thing you must know about Metro, is that it is an umbrella project for various WS related projects viz. JAX-WS, JAXB, WSIT, JAX-WS-Commons etc.

Each of these components has two parts, API (specs) and the implementation part called as reference implementation (RI). The specs are defined in the 'javax.xml.ws', 'javax.xml.bind' etc. and the RI go in the 'com.sun.xxx' packages.

Now somewhere around JDK 6, update 4, sun/oracle started bundling these APIs + RIs in the JDK it self, and kept updating these with updates to the JDK.

As of the last JDK 6 update31, the JDK contains the following verisions of JAXWS and JAXB API, and RI

JDK6 u31 - JAXB API @ 2.1 & RI @ 2.1.10, JAXWS API @ 2.1 and RI @ 2.1.6

Now if you go to the http://jaxb.java.net and http://jax-ws.java.net pages, and see the last release under 2.1.x , you will see that JAXB RI is at 2.1.13 and JAXWS RI is 2.1.7, i.e. the RI implementations of the 2.1 spces that are bundled with the latest JDK 6 update are a couple of versions behind the ones released under Metro. So to use the latest 2.1 jars, simply copy the API + RI jars to your classpath, as described here http://jax-ws.java.net/2.1.7/docs/ReleaseNotes.html#Running_on_top_of_JDK_6.

To make matters more confusing, Metro the umbrella project has it's own version numbers, which are as of today, 1.5, 2.0, 2.0.1, 2.1, 2.1.1, 2.2

Metro 1.5 was the last build that bundled the 2.1 spces and the latest RIs for that specs, i.e. Metro 1.5 contains JAXWS and JAXB APIs @ 2.1 and JAXWS RI @ 2.1.7 and JAXB RI @ 2.1.13.

Metro 2.0 onwards, bundles JAXB and JAXWS APIs v2.2 and the latest RI as of the release data. e.g. the latest METRO release 2.2 bundles JAXB RI 2.2.5 and JAXWS RI 2.2.6.

But there is a catch, JDK 6 bundles v2.1 for JAXWS and JAXB (APIs + RI), and if you simply use JAXWS , JAXB v2.2 jars in your classpath it won't work. You'll have to use the endorsed jar mechanism, as described here http://jax-ws.java.net/2.2.3/docs/ReleaseNotes.html#Running_on_top_of_JDK_6.

So for any Metro release 2.0 and above, you'll need to copy the jax-ws-api.jar and jaxb-api.jar files under $JAVA_HOME/jre/lib/endorsed, or use the -Djava.endorsed.dirs system property.

And some more fun, Metro is just not an umbrella project that contains the jax-ws, jaxb projects (amongs other), but it also makes a uber jar out of these projects.

So e.g., metro's webservices-api.jar contains jaxws-api.jar , jaxb-api.jar (RI) + APIs from other children projects like WSIT, jax-ws-commons etc.

And webservices-rt.jar contains jaxws-rt.jar, jaxb-rt.jar , + RT jars of other children projects like WSIT, jax-ws-commons etc.

So to sum up -

If you want to develop your WS against JAXWS/JAXB v2.1 specs, simply use the JDK 6 (any update past u04). If you want to be absolutely sure to use the latest APIs + RIs versions of 2.1 specs, simply use the last 2.1.x release jars from jaxws and jaxb . i.e. use jax-ws 2.1.7 and jaxb 2.1.13, in your classpath, [ Or you can use the Metro 1.5's webservices-api.jar and webservices-rt.jar as they bundle the jaxws/jaxb/wsit/.. ]

If you want to develop your WS against the latest JAXWS/JAXB v2.2 specs, then you'll have to use jax-ws v2.2.6 and jaxb ver 2.2.5 jars [ Or alternatively use Metro 2.2's webservices-api.jar and webservices-rt.jar as they bundle the jaxws/jaxb/wsit..] But you'll have to use the endorsed jar mechanism as described above, in order to override the jdk included jaxws/jaxb v2.1 jars.

My recommendation - If v2.1 is OK with you use the Metro 1.5 jars (webservices-api, webservices-rt). If you need v2.2 use Metro 2.2 jars (webservices-api, webservices-rt), and make sure to put webservices-api.jar in the endorsed dir.

You'll need metro jars (webservices-[api,rt].jar) if you are going to use stuff like fastinfosets, Mtom, etc, as the JDK bundled jars or for that matter just the jaxws-ri.jar and jaxb-ri.jar won't give you those features.

Hope this rather long mail was helpful in clearing up some things.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top