JAX-WS webservice with Spring Boot and JAX-WS RI

This tutorial shows you how to create a SOAP webservice with JAX-WS RI and Spring Boot. You will write a Java class that adheres to the JAX-WS standard and generate a SOAP endpoint from it (including the wsdl).

Get the sources for this tutorial

What to do

At first, set up your pom.xml file. Besides stuff for Spring Boot, you’ll include jaxws-rt (the runtime) and jaxws-spring (a helper library for integrating jaxws-rt with Spring). Exclude the Spring dependencies from jaxws-spring to avoid conflicts.

Now, onto the Application class, which is the main entry to your application. As you’ll see, you will import an xml config file (jaxwsconfig.xml) which contains bean wiring for JAX-WS RI. Also, you need to register WSSpringServlet to receive incoming requests.

Next comes the Service class. The service doesn’t do very much besides greeting the client upon being called. Through the @Component annotation you can make sure it gets picked up, added to the Spring context and will be given a name. You will reference the service by the name later to let it handle the web service requests.

Lastly, you have to add an xml file for wiring the service on the endpoint:

Build and run it

Build it: mvn clean package
Run it: java -jar helloJaxws-0.0.1-SNAPSHOT.jar

Now open http:/localhost:8080/hello?wsdl to see the generated wsdl file. Your webservice has been deployed, and you could now create a client for it.

What to do next?

Here are some hints what topics you could explore next.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s