I am trying to add a soap endpoint to my application with some rest endpoints. But when I add the beans for SOAP, the application startup fails with the below error.
The bean 'messageDispatcherServlet', defined in class path resource [org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [com/test/app/config/WebServiceConfig.class] and overriding is disabled.
The bean I am adding for SOAP is as below:
@Bean public ServletRegistrationBean<?> messageDispatcherServlet(ApplicationContext applicationContext) { MessageDispatcherServlet servlet = new MessageDispatcherServlet(); servlet.setApplicationContext(applicationContext); servlet.setTransformWsdlLocations(true); return new ServletRegistrationBean<>(servlet, "/ws/*"); }
What am I missing here? Can't both SOAP and REST coexist?