Java 6 web services and Tomcat?
I recently installed Java SE 6 and want to know how to use the web services that come with it with Tomcat 5.5.
Searching the internet yields no answers.
Specifically, I need to know what needs to go into the web.xml file to publish the web service, whether another xml file is needed, whether Tomcat should have any jars added to its internal directories, etc.
I realize that some of these questions are Tomcat-specific, and I plan to post on a Tomcat-related forum as well, but these are all Java SE 6 -related questions, so I'm hoping that posting here should yield some answers too.
Thanks in advance,
Inna
[647 byte] By [
innanilla] at [2007-11-27 10:45:43]

# 1
TBH i have no idea, but jdk 1.5_12 and jax-ws uses a lot of Jars.
Try using a IDE, netbeans makes creating a web service using jax-ws really easy (it generates all of the context xml files needed).
As for deployment, its like a jsp page, you can put a .war in there or a folder in the webapps folder with the name you wish for your WS.
That folder should contain:
META-INF
-context.xml
-manifest.mf
WEB-INF
-Lib
-Classes
-web.xml
-sun-jaxws.xml
But, truly its easier to use a IDE, and netbeans generates all this for you, you just have to move the build/web folder to the webapps/myWS folder or the dist/*.war file to the webapps folder.
As for the how to do it, if you plan on using netbeans or any other IDE, search their home page for a tutorial, usually its self explanatory.
# 3
Thanks for your reply.
I found how to do this, though it took a lot of searching.
I'm including the info in this post in case it can help anyone in the future.
This info was found on: http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=51&t=004355 and is copied almost verbatim below.
The steps are:
Download and unpack the jax-ws (use https://jax-ws.dev.java.net/jax-ws-20-fcs/)
Copy all *.jar from the lib dir into $CATALINA_HOME/shared/lib
Create a directoy for the service under $CATALINA_HOME/webapps
Copy the class structure from the web service into WEB-INF/classes in that directory
Create a sun-jaxws.xml in WEB-INF
Create web.xml in WEB-INF
Start tomcat. Done
The web.xml should look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
<web-app>
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>HelloService</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloService</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
</web-app>
The sun-jaxws.xml can look like this:
<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">
<endpoint name="HelloService"implementation="com.techyatra.hellows.HelloServer" url-pattern="/hello" />
</endpoints>
After starting tomcat you can access the service under
http://localhost:8080/HelloService/hello
Hope this helps someone.
Inna