Engineering Full Stack Apps with Java and JavaScript
A web container like tomcat can deploy servlets, jsps and web services.
Web components are generally deployed in the web container as war files.
These war files might contain standard configuration files such as web.xml and vendor specific configuration files such as sun-jaxws.xml.
To host web services, a web container relies on a servlet interceptor, like WSServlet for tomcat that mediates between the client and the web service implementation class (SIB), which needs to be configured in the web.xml file.
However, with JAX-WS, this is taken care of "behind the scenes" (stricken out in the example). The endpoint and url pattern details are read from sun-jaxws.xml file and servlet configuration for WSServlet has no effect here.
The <endpoints> element of sun-jaxws.xml contains one or more <endpoint> elements.
Each endpoint represents a port in the WSDL.
The WSServletContextListener configured in the web.xml as a listener class parses sun-jaxws.xml and sets up all deployed endpoints.
Prerequesites
Setup and start tomcat
Download the jax-ws ri zip, unzip it and copy paste the required jars into lib directory of tomcat.
Development and deployment
Build the class files and place class files under WEB-INF/classes according to your package structure.
Create files web.xml and sun-jaxws.xml (with required details) under WEB-INF folder.
Package your web service classes and configuration files into a war file.
Restart the server (or refresh the app list in the manager gui)
Verifying the results
Run the service url to see the service.
Append ?wsdl to the url to see the wsdl.
Above steps are detailed in the lab note.