如何在 spring-boot 中使用 WSDL? [英] How to use WSDL with spring-boot?
本文介绍了如何在 spring-boot 中使用 WSDL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有客户端提供的 WSDL 和模式文件.我需要使用此 WSDL 文件创建 Spring-boot SOAP Web 服务.我已经谷歌了它和我能找到的所有示例,他们使用 spring 自动生成 wsdl.如何使用我的 WSDL 生成 SOAP 服务?
I have WSDL and schema files provided by client. I need to create Spring-boot SOAP web service with this WSDL file. I have google it and all the examples that I can find, they have auto-generate the wsdl with spring.How can I use my WSDL to generate the SOAP service?
推荐答案
以下是将现有 wsdl 与 Spring-Ws 和 Spring-boot 结合使用的常见步骤.
Here are the common steps to follow to use your existing wsdl with Spring-Ws and 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;
}
}
- 在您的 pom.xml 中,使用jaxb2-maven-plugin"插件从您的 wsdl 生成类.
- 在 Spring-WS 中,您必须自己编写端点.没有端点的代码生成.它很容易写.您可以按照 spring 网站上的教程/指南进行操作.
这篇关于如何在 spring-boot 中使用 WSDL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文