In a previous topic we learned how to develop JAX-WS web service With Top-Down approach (contract first). The service was published with javax.xml.ws.Endpoint. But in Real World you want to deploy your services in a servlet engine or maybe in application server :-). So now im going to explain how to deloy our last example in Apache Tomcat

Used technologies

JDK 1.8
Apache Tomcat 8.0.47
Maven 3.2
Eclipse IDE

1. create maven project in eclipse

After finising the wizrad, make sure that targeted runtime is pointing Tomcat

2. Generate Code

At first copy wsdl folder that contains wsdls and xsd files from previous article and execute the following command
wsimport -d ./generated -s ./src/main/java -p com.wstutorial.ws ./wsdl/TutorialService.wsdl
Now copy the TutorialServiceImpl.java and your project should be error-free

3. Adjust the pom file


Info! The depenedencies of jaxws-rt are not visibile in eclipse project structure, the will be only affected during maven build cycle mvn package
If you want to use embedded tomcat server in eclipse, you have to copy JAXWS RI jars to WEB-INF\lib

4. Perpare deployment

4.1 web.xml

The web.xml should look like below.
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >


4.2 sun-jaxws.xml

Create a file named sun-jaxws.xml in WEB-INF folder and change it like below.
<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">

4.3 build and deploy

mvn clean package
Copy target/ws-topdown-tomcat.war to %TOMCAT_HOME%/webapps and start tomcat

5. Check the url