java - Spring ws 和多个模式

标签 java spring-ws

我的 servlet 中有 spring 配置...

<context:component-scan base-package="org.knowledgebase.webservice"/>
<sws:annotation-driven/>

<sws:dynamic-wsdl id="carService"
                  portTypeName="carService"
                  locationUri="/carService/">
    <sws:xsd location="classpath:/wsDefinition/car/properties.xsd"/>
    <sws:xsd location="classpath:/wsDefinition/car/carServiceSimple.xsd"/>
</sws:dynamic-wsdl>

<bean class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
    <property name="soapVersion">
        <util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_11"/>
    </property>
</bean>

和同一文件夹中的两个 XSD - carServiceSimple.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
       xmlns:pro="http://bar.foo/properties"
       targetNamespace="http://bar.foo"
       elementFormDefault="qualified">

<xs:import schemaLocation="properties.xsd" namespace="http://bar.foo/properties"/>

<xs:element name="StoreCarRequest">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="ID" type="xs:string"/>
            <xs:element name="Name" type="xs:string"/>
            <xs:element name="Properties" type="pro:PropertiesType"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:complexType name="StoreCarResponse">
    <xs:sequence>
        <xs:element name="Status" type="xs:string"/>
    </xs:sequence>
</xs:complexType>

<xs:element name="UpdateCarRequest">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="ID" type="xs:string"/>
            <xs:element name="Properties" type="pro:PropertiesType"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:complexType name="UpdateCarResponse">
    <xs:sequence>
        <xs:element name="Status" type="xs:string"/>
    </xs:sequence>
</xs:complexType>
</xs:schema>
  • 属性.xsd:

但是在Glassfish 3上部署后,出现异常:多个元素需要Commons XMLSchema。请将Commons XMLSchema放在类路径中。

Spring ws 文档第 5.3.1 节: 如果您想使用多个模式,无论是通过包含还是导入,您都需要将 Commons XMLSchema 放在类路径中。如果 Commons XMLSchema 位于类路径上,则上述元素将跟随所有 XSD 导入和包含,并将它们作为单个 XSD 内联到 WSDL 中。

“Commons XMLSchema”是什么意思?我该如何解决?谢谢。

我在类路径中有两个 XSD 文件(在 war 中:WEB-INF\classes\wsDefinition\car)。当我从 servlet 中删除行时,会生成可访问的 wsdl,但是当我想基于此 wsdl 创建 SoapUI 项目时,SopaUI 显示错误:无法找到 properties.xsd。

最佳答案

您需要包含 Commons XMLSchema 的 jar 文件项目在您的 WEB-INF/lib 目录中。

关于java - Spring ws 和多个模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6917920/

相关文章:

java - Spring 启动 ws : No adapter for endpoint

java - Spring JPA Hibernate 处理大型数据库

java - 什么是非内存资源?

java - 如何将本地可绘制图像传递给模型类?

java - 如何在 observable 上编写我自己的操作以将所有内容映射到常量?

java - 在 View 层次结构的顶部插入 Android View

java - 如何在Java中保持原始排序不变的情况下基于比较器执行排序

java - Spring 异步方法不适用于 EndPoint

spring - 是否可以在 Spring WS web 服务中重命名响应 namespace 前缀?

java - Spring:记录传出的 HTTP 请求