views:

1419

answers:

4

After noticing Java 6 includes javax.xml.ws, I'm able to create a standalone web service. How would I go about hosting that in Tomcat 6?

+1  A: 

You will need to download the JAX-WS RI (Reference Implementation) jax-ws.dev.java.net. The https://jax-ws.dev.java.net/nonav/2.1.2m1/docs/samples.html page lists some tips at the bottom of the page on setting up Tomcat for JAX-WS RI.

Specifically for Tomcat 6, you will need to:

Edit $CATALINA_HOME/conf/catalina.properties and set shared.loader={RI Installation Directory}/lib/*.jar. If you are running multiple instances of Tomcat, then edit CATALINA_BASE/conf/catalina.properties for that particular instance. The same technique can be used with Tomcat 5.x if you don't like to copy all the jars to $CATALINA_HOME/shared/lib

Courtney Palit
jdk6 comes with , as far as I understand, a jax-ws implementation. I can generate a silly standalone web service(serviced over http) w/o any other dependencies. What is the jax-ws ri needed for when deploying on tomcat ?
nos
As far as I can tell, it is included with the jdk6 (version 2.1). The same ref implementation is available as a separate download so that you can more easily add those libraries to app servers like Tomcat. The separate download also allows you to move to a later version of jax-ws than in included with jdk6. From what I can tell, the metro download's ant task will work great with Tomcat 5.x but you may need the few extra steps I listed for Tomcat 6 due to the finickiness of Tomcat 6's lib-loading behavior. I need to poke around with it to see where Tomcat 6 likes the jars best.
Courtney Palit
+2  A: 

Download metro from here and execute this jar as

java -jar metro-2_0-ea.jar

The metro directory contains two ant files, metro-on-glassfish.xml and metro-on-tomcat.xml. These two files are used to install the Metro binaries into the respective web containers.

The installation process for Tomcat:

  1. shutdown.bat (Tomcat shutdown)

  2. Execute below line on command prompt

ant -Dtomcat.home= -f /metro-on-tomcat.xml install

startup.bat (Tomcat start)

the installation process copies the two Metro jar files into Tomcat's shared/lib directory. No Tomcat configuration files are modified.

Thomman
Thanks; I did as you adviced, but while I can deploy the webservice just fine under JBoss when I try with Tomcat 5.5 I get a "javax.servlet.ServletException: Class ...WebServiceMain is not a Servlet" visiting the WSDL page. Any idea?
Manrico Corazzi
A: 

Or you can use Apache CXF which is a full-featured JAX-WS implementation. No extra configurations - only one Servlet.

Bozho
A: 

Watch out for encription support, compatibility with WSDL 1.1 and SAAJ, trying to be the first to use a new API usually leads to problems.

I would recomend Axis2 instead.

Just my two cents.

Raul Lapeira Herrero