By Alx: June 2019


In this tutorial we want to show how to build a saop web serivce with spring boot. Spring boot uses Spring-WS, which allows only contract-first. Hence we need to start from a contract definition, either from a xml schema (xsd) or from WSDL. We will flow the contract-first with wsdl approach

Used technologies

JDK 1.8
Maven 3.2

WSDL First

The wsdl document contains the five standard elements: types, message, portType, binding and service.
The wsdl provides 3 operations: deleteTutorial, updateTutorial and getTutorials

pom xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""


		<relativePath /> <!-- lookup parent from repository -->




The only used dependency isspring-boot-starter-web-services, it includes the needed dependencies for using Spring-WS
Maven plugin maven-jaxb2-plugin for generating Java sources from WSDL

  • schemaDirectory: Directory where WSDL file can be found.
  • schemaIncludes : Here we can specify which file should be used. In our case a WSDL file
  • generateDirectory - Target directory for the generated code, In our case is unspecified, so the default generateDirectory will be used target/generated-sources/xjc
  • generatePackage is not set, consequently the package name will be derived from the wsdl. Exactly from targetNamespace

Let's generate code

wsdl to code

Implementing the endpoint

A simple implemenation with dummy data



  • @EnableWs: Provides spring web service configuration
  • We define DefaultWsdl11Definition with @Bean(name = "tutorialService"). tutorialService will be the name of the WSDL in the URL
    • wsdl11Definition.setWsdl, spicify the localtion of the wsdl
  • MessageDispatcherServlet will be used to handle the http requests
    • Setting *ApplicationContext* is required
    • The ServletRegistrationBean maps all the incoming requests with URI /wsdlfirst/* to the servlet
  • The url of the wsdl will be: http://localhost:8080/wsdlfirst/tutorialService.wsdl

Run the SOAP Web Service

Test with soapUI

soapUI wsdl