Spring 首先启动 wsdl - 将 url 更改为 wsdl

Spring Boot wsdl first - change url to wsdl

我正在使用 Spring Boot 1.3.* 构建合同优先 Web 服务。我在 How to use WSDL with spring-boot? 查看了问题的答案。这很好

@EnableWs
@Configuration
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/*");
}

//http://localhost:8080/ws/services.wsdl --bean name is set to 'services'
@Bean(name = "services")
public Wsdl11Definition defaultWsdl11Definition() {
    SimpleWsdl11Definition wsdl11Definition = new SimpleWsdl11Definition();
    wsdl11Definition.setWsdl(new ClassPathResource("/schema/MyWsdl.wsdl")); //your wsdl location
    return wsdl11Definition;
}
}

我的 wsdl 现在位于 http://localhost:8080/ws/services.wsdl 。问题是,将成为此 Web 服务消费者的应用程序需要将 wsdl url 编写为

http://localhost:8080/ws/services?wsdl

我怎样才能做到这一点?

要将 urlrewrite 配置为 bean,请检查此

这将在后台转发,用户不会收到通知。在您的 urlrewrite.xml

中添加此规则
<rule>
    <from>/ws/services?wsdl</from>
    <to>/ws/services.wsdl</to>
</rule>