首页 > 解决方案 > 使用 Spring Web 服务针对 WSDL 验证 SOAP 消息

问题描述

使用 Spring Web 服务是否可以根据 WSDL 的 types 元素中定义的模式来验证 soap 消息?

背景:给定第三方 WSDL,其架构直接在 types 元素中定义

<definitions>
  <types>
    <xsd:schema>
      <xsd:element name="messageBody">
        ...
      </xsd:element>
    </xsd:schema>
  </types>
  ...
</definitions>

我需要生成一个 SOAP Web 服务来验证针对这个嵌入式模式的请求消息。

spring 文档 ( https://docs.spring.io/spring-ws/docs/3.0.10.RELEASE/reference/ ) 建议使用 PayloadValidatingInterceptor 进行验证。然而,这个拦截器似乎只适用于 XSD 文档。

我考虑过手动或以编程方式从 WSDL 中提取模式,然后使用提取的 xsd 文档配置 payloadVaidatingInterceptor。然而,这两者都有其缺点。

理想情况下,我想直接使用 WSDL。例如: payloadValidatingInterceptor.setXsdSchema("service.wsdl");

其他 Web 服务框架(例如 CXF)能够做到这一点。Spring Web 服务是否能够针对 WSDL 模式进行验证?或者这是框架的限制?

标签: soapspring-ws

解决方案


推荐阅读