Producing a SOAP Web service in Spring Boot is pretty straight forward if you follow the instructions on their website: https://spring.io/guides/gs/producing-web-service/.
However, the problem I was facing is that , instead of an XSD, I had a WSDL.
In order to generate the API's and host the WSDL, there were slight changes from the usual process as mentioned in the above link.
Here are those changes.
1) In the Maven POM file
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>com.abc.webservice.api</packageName>
<wsdl>true</wsdl>
<xmlschema>false</xmlschema>
<schemaFiles>service.wsdl</schemaFiles>
<schemaDirectory>${project.basedir}/src/main/resources/</schemaDirectory>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
2) The service.wsdl has to be kept in the /src/main/resources/ folder.
3)Note changes in the WebServiceConfig
@Configuration @EnableWs
public class WebServiceConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/ws/*");
}
@Bean(name = "countries")
public Wsdl11Definition wsdlDefinition() {
SimpleWsdl11Definition wsdl11Definition = new SimpleWsdl11Definition();
wsdl11Definition.setWsdl(new ClassPathResource("service.wsdl"));
return wsdl11Definition;
}