【问题标题】:ServletRegistrationBean doesn't works for the multiple URL mapping pathsServletRegistrationBean 不适用于多个 URL 映射路径
【发布时间】:2020-09-16 18:32:19
【问题描述】:

我正在开发代码查看https://howtodoinjava.com/spring-boot/spring-boot-soap-webservice-example/,在下面的bean中我想允许为/*/service/*执行请求,所以我改为

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

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

当我们执行/service/* url 时,以下配置不起作用。我们如何解决这个问题?

【问题讨论】:

  • 您是否尝试过将更具体的 url 映射放在首位?我不会有太多帮助,因为我已经很长时间没有使用 SOAP 做了很多事情了。
  • 是的,我已经尝试过先更具体,然后再更通用,但没有奏效。你能帮我解决这个问题吗?
  • 你能不能把/*改成/**,还要确保wsdl11Definition.setLocationUri根据端点正确使用,然后再试一次
  • 看看答案是否有帮助stackoverflow.com/questions/26464931/…

标签: spring spring-boot soap spring-ws


【解决方案1】:

映射对我有用。我下载了示例并根据您的问题进行了更改。

我看到已注册的映射(日志)和加载的 wsdl(浏览器),如屏幕截图所示。

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

Spring Boot 日志,WSDL 肥皂请求响应

不确定什么不适合您。 “当我们执行 /service/* url 时,以下配置不起作用。”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-26
    • 1970-01-01
    • 1970-01-01
    • 2015-12-16
    • 2022-11-27
    • 2014-03-08
    • 2017-11-13
    相关资源
    最近更新 更多