gpt4 book ai didi

java - Spring Boot wsdl 首先 - 将 url 更改为 wsdl

转载 作者:太空宇宙 更新时间:2023-11-04 12:52:23 24 4
gpt4 key购买 nike

我正在使用 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,请检查此 tuckey-url-rewrite-filter-java-class-configuration

这将在后端转发,用户不会收到通知。在您的 urlrewrite.xml 中添加此规则

<rule>
<from>/ws/services?wsdl</from>
<to>/ws/services.wsdl</to>
</rule>

关于java - Spring Boot wsdl 首先 - 将 url 更改为 wsdl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35698046/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com