2011-08-02 125 views
2

我有我的servlet spring配置...春天的WS多种模式

<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> 

,并在同一个文件夹2周的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部署后,该异常出现了:多元素需要共享XMLSchema.Please把共享的XMLSchema类路径上。

Spring ws doc章节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。

回答

3

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

+0

UPPS它是图书馆,谢谢beny23。这是我最愚蠢的问题。我得到这个错误时可能已经太晚了。 – Ziletka

3

如果有人在这里的土地...添加这个依赖于你的pom.xml

<dependency> 
    <groupId>org.apache.ws.xmlschema</groupId> 
    <artifactId>xmlschema-core</artifactId> 
    <version>2.0.1</version> 
</dependency>