soap - 如何将 WSDL 与 spring-boot 结合使用?

标签 soap spring-boot spring-ws

我有客户端提供的 WSDL 和架构文件。我需要使用此 WSDL 文件创建 Spring-boot SOAP Web 服务。我在 google 上搜索了所有我能找到的示例,它们使用 spring 自动生成了 wsdl。我如何使用 WSDL 来生成 SOAP 服务?

最佳答案

以下是将现有 wsdl 与 Spring-Ws 和 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 网站上的教程/指南进行操作。
  • 关于soap - 如何将 WSDL 与 spring-boot 结合使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33773346/

    相关文章:

    java - 由于 SOAP 信封/ header 混淆,Tomcat 中的任意 HTTP 501 未实现错误

    php - SoapClient : how to pass multiple elements with same name?

    spring - 使用 RedisTemplate 将不同的对象迭代为 String

    spring-boot - spring boot中redis和solr的指标

    java - Spring Boot - 如何将自定义 header 添加到 SOAP 响应?

    java - Camel 泉-WS。设置自定义 SOAP header

    java - Magento Java Soap 无效的 XML 响应

    java - 如何在客户端应用程序中访问Web服务?

    java - Spring bean后处理器: inject a value

    java - 为什么我们应该在 WSDL 中有 SOAP 位置?