Search code examples
springspring-bootsoapspring-ws

ServletRegistrationBean doesn't works for the multiple URL mapping paths


I was developing code looking at https://howtodoinjava.com/spring-boot/spring-boot-soap-webservice-example/, In the below bean I want to allow request to be executed for /* and /service/*, so I changed to

@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext){
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setApplicationContext(applicationContext);
    servlet.setTransformWsdlLocations(true);
    return new ServletRegistrationBean(servlet, "/service/*");
}

To

@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext){
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setApplicationContext(applicationContext);
    servlet.setTransformWsdlLocations(true);
    return new ServletRegistrationBean(servlet, "/*","/service/*");
}

Below configurations doesn't works when we execute the /service/* url. How can we fixed this ?


Solution

  • The mapping works for me. I downloaded the example and made changes as per your question.

    I see the mappings registered(log) and the wsdl(browser) loaded as shown in the screenshot.

    Mapping servlet: 'messageDispatcherServlet' to [/*, /service/*]

    Spring Boot Log, WSDL Startup log and wsdl Soap Request Response

    Soap Request Response

    Not sure what's not working for you. "Below configurations doesn't works when we execute the /service/* url."