我的 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/