5 Replies Latest reply on Apr 19, 2007 4:53 PM by thomas.diesler

    wstools failing on XSDs using xs:import

    mscongdon

      Using the wstools shipped with the JBossWS stack in JBoss 4.0.4.GA (and using Java 1.5.0_06), we can successfully generate artifacts for our WSDL if the XSD it references contains every xs:complexType therein.

      However, we want to reuse many XML structures. Hence we have put our re-useable xs:complexType's into separate .xsd files. We then simply import them (they're in a different namespace) into our main XSD. So here's a recap of our files.

      OurService.wsdl

      <wsdl:definitions name="OurWebService"
       targetNamespace="http://www.ourcompany.com/wsdl/OurService"
       xmlns:tns="http://www.ourcompany.com/wsdl/OurService"
       xmlns:our="http://schemas.ourcompany.com/public"
       xmlns:xs="http://www.w3.org/2001/XMLSchema"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
       xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
       xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/">
      
       <wsdl:types>
       <xs:schema targetNamespace="http://schemas.ourcompany.com/public"
       elementFormDefault="qualified" attributeFormDefault="unqualified">
       <xs:include schemaLocation="xsd/public/OurService.xsd" />
       </xs:schema>
       </wsdl:types>
      
       <wsdl:message name="OurServiceInputMessage">
       <wsdl:part name="parameters" element="our:OurServiceRequestMessage" />
       </wsdl:message>
       <wsdl:message name="OurServiceOutputMessage">
       <wsdl:part name="result" element="our:OurServiceResponseMessage" />
       </wsdl:message>
      
      ...



      OurService.xsd
      <?xml version="1.0" encoding="utf-16"?>
      <xs:schema targetNamespace="http://schemas.ourcompany.com/public"
       xmlns="http://schemas.ourcompany.com/public"
       xmlns:common="http://schemas.ourcompany.com/common"
       xmlns:xs="http://www.w3.org/2001/XMLSchema"
       elementFormDefault="qualified" attributeFormDefault="unqualified">
      
       <xs:import namespace="http://schemas.ourcompany.com/common" schemaLocation="../common/BaseRequest.xsd" />
       <xs:import namespace="http://schemas.ourcompany.com/common" schemaLocation="../common/BaseResponse.xsd" />
      
       <xs:element name="OurServiceRequestMessage" type="OurServiceRequestMessageType" />
       <xs:element name="OurServiceResponseMessage" type="OurServiceResponseMessageType" />
      
       <xs:complexType name="OurServiceRequestMessageType">
       <xs:complexContent>
       <xs:extension base="common:BaseRequestType">
       <xs:sequence>
       <xs:element name="Field1" type="xs:string" maxOccurs="unbounded"/>
       <xs:element name="Field2" type="xs:string" maxOccurs="unbounded"/>
       </xs:sequence>
       </xs:extension>
       </xs:complexContent>
       </xs:complexType>
      
       <xs:complexType name="OurServiceResponseMessageType">
       <xs:complexContent>
       <xs:extension base="common:BaseResponseType">
       <xs:sequence>
       <xs:element name="Field3" type="xs:string" maxOccurs="unbounded" />
       </xs:sequence>
       </xs:extension>
       </xs:complexContent>
       </xs:complexType>
      
      .....
      </xs:schema>



      BaseRequest.xsd
      <?xml version="1.0" encoding="UTF-8"?>
      <xs:schema
       targetNamespace="http://schemas.ourcompany.com/common"
       xmlns="http://schemas.ourcompany.com/common"
       xmlns:xs="http://www.w3.org/2001/XMLSchema"
       elementFormDefault="qualified" attributeFormDefault="unqualified">
      
       <xs:complexType name="BaseRequestType">
       <xs:sequence>
       <xs:element name="UserName" type="xs:string" nillable="false" />
       <xs:element name="Password" type="xs:string" nillable="false" />
       </xs:sequence>
       </xs:complexType>
      </xs:schema>
      


      BaseResponse.xsd
      <?xml version="1.0" encoding="UTF-8"?>
      <xs:schema
       targetNamespace="http://schemas.ourcompany.com/common"
       xmlns="http://schemas.ourcompany.com/common"
       xmlns:xs="http://www.w3.org/2001/XMLSchema"
       elementFormDefault="qualified" attributeFormDefault="unqualified">
      
       <xs:complexType name="BaseResponseType">
       <xs:sequence>
       <xs:element name="ReturnCode" type="xs:int" nillable="false" />
       </xs:sequence>
       </xs:complexType>
      </xs:schema>
      


      And here is the wstools config file we use when running our WSDL -> Java approach:
      <?xml version="1.0" encoding="UTF-8"?>
      <configuration xmlns="http://www.jboss.org/jbossws-tools"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.jboss.org/jbossws-tools http://www.jboss.org/jbossws-tools/schema/jbossws-tool_1_0.xsd">
      
       <global>
       <package-namespace package="com.ourcompany.service.types" namespace="http://www.ourcompany.com/wsdl/OurService" />
       </global>
       <wsdl-java file="../source/web/src/WEB-INF/wsdl/OurService.wsdl">
       <mapping file="../../web/src/WEB-INF/mapping_ourservice.xml" />
       </wsdl-java>
      
      </configuration>



      When we run this via the wstools ANT task, it freezes up with a StackOverflowError.

      We had the same issue (with a different error than the stack overflow) with JWSDP 2.0.

      Is JBossWS (or any Web Services tool) supposed to support the <xs:import> and <xs:include> standard schema functionality?

      If we put all types (including BaseRequest and BaseResponse) into our master OurService.xsd, all the artifacts are generated just fine. It just doesn't work when they're in separate files.

      Also, here's our directory structure...
      WEB-INF
       wsdl
       OurService.wsdl
       xsd
       common
       BaseRequest.xsd
       BaseResponse.xsd
       public
       OurService.xsd


      Please advise.

      Thanks in advance,
      Michael