Deploy JAX-WS service on tomcat

This tutorial provides a step-by-step guide on how to build and deploy JAX-WS web service on Tomcat.

Throughout this tutorial, we create a very simple SOAP web service and finally deploy it on Tomcat application server.


  • Eclipse IDE (Neon release)
  • Java 1.8
  • Apache Tomcat 8

1. Create Maven web project

Create a maven web project using this tutorial and name your project as JAXWSSoapServiceUsingTomcat.

The structure of the generated project looks like the following:

JAXWS Project

2. Add JAX-WS dependency

After creating the web project, the first step is to add JAX-WS dependency into pom.xml, here we go:

3. Create service endpoint

The next step is to create an interface which exposes the different methods provided by our web service, so we create a new class called HelloWorldService under com.programmer.gate package.

4. Create service implementation

The next step is to define the implementation class which encapsulates our business logic, so we create a new class called HelloWorldServiceImpl under com.programmer.gate.

For more details about the different JAX-WS annotations used in the above classes, check our previous complete tutorial.

5. Add servlet listener to web.xml

Now that we create the service interface and implement the business details of the service.

The next step is to define the JAX-WS servlet listener under web.xml and inform tomcat to automatically load and map our service on startup. Here we go:

6. Create sun-jaxws.xml

The final step is to define sun-jaxws.xml file.

This file describes the different endpoints defined under your application and it’s required when deploying your service on non-Java EE5 servlet containers. Its role is to tell web.xml to which endpoint a servlet request must be dispatched.

So we create sun-jaxws.xml under WEB-INF as the following:

Here we’re saying that every request corresponding to /hello servlet is handled by HelloWorldService endpoint which is implemented by HelloWorldServiceImpl.


7. Test the service

Now that out application is ready to be published on Tomcat. After publishing it and starting tomcat, you can access the service wsdl through “http://localhost:9090/soap/hello?wsdl” knowing that 9090 is the tomcat port.

It is worth to mention that in order to test the service, you should create a client application or use any web service client tools like: SoapUI.

Here below is a screenshot from SoapUI:

SOAP Hello World

0 0 vote
Article Rating

Hussein Terek

Founder of, I have a passion in software engineering and everything related to java environment.

You may also like...

1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
11 months ago

I am not able to add jax-ws-rt dependency. It shows missing under maven dependencies.