春天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>
properties.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。
I have spring configuration in my servlet...
<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>
and two XSDs in the same folder - 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>
properties.xsd:
But after deploying on Glassfish 3, the exception is arisen: Multiple elements requires Commons XMLSchema.Please put Commons XMLSchema on the classpath.
Spring ws doc section 5.3.1:
If you want to use multiple schemas, either by includes or imports, you will want to put Commons XMLSchema on the class path. If Commons XMLSchema is on the class path, the above element will follow all XSD imports and includes, and will inline them in the WSDL as a single XSD.
What does "Commons XMLSchema" mean? How can I fix it? Thx.
I have both XSD files on the classpath (in war: WEB-INF\classes\wsDefinition\car). When I remove line from servlet, then is generated wsdl accessible, but when I want create SoapUI project base on this wsdl, the SopaUI shows error: is not possible find properties.xsd.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在 WEB-INF/ 中包含 Commons XMLSchema 项目的 jar 文件lib 目录。
You'll need to include the jar file for the Commons XMLSchema project in your WEB-INF/lib directory.
如果有人登陆这里...将此依赖项添加到您的 pom.xml
If someone lands here... add this dependency to your pom.xml