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

Learn how to create a SOAP webservice with JAX-WS RI and Spring Boot.

Download source code

What to do

Use spring initializr to create a Spring Boot application with Spring Web dependency.

Open your pom.xml and 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.

<!– JAX-WS –>
<!– Spring JAX-WS Integration –>
view raw pom.xml hosted with ❤ by GitHub

Configure the Application class, by importing an xml config file (jaxwsconfig.xml) which contains bean wiring for JAX-WS RI and register WSSpringServlet to receive incoming requests.

@ImportResource(locations = "jaxwsconfig.xml")
public class TutorialJavaJaxwsApplication {
public static void main(String[] args) {
SpringApplication.run(TutorialJavaJaxwsApplication.class, args);
public ServletRegistrationBean servletRegistrationBean() {
return new ServletRegistrationBean(new WSSpringServlet(), "/hello");

Create a GreetingService class which greets the client upon being called. You will reference the service by the name later to let it handle the web service requests.

@Component(value = "greetingService")
public class GreetingService {
public String greeting() {
return "Hello World!";
view raw GreetingService.java hosted with ❤ by GitHub

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

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