Unable to import XML schemas into Studio when they have circular import references

Technote (troubleshooting)


Problem(Abstract)

In some cases you may have two XML schema documents which import each other. For example, schema A imports schema B which imports schema A. When you try to import schema A into WebSphere Cast Iron Studio using the 'Add Document' context menu option under 'XML Schemas' on the Project tab, you may get an error dialog with a message like the following:

Unable to add selected document to the project.
type '<typename>@<URL>' not found.

In Studio's error.log you may also see errors like the ones below (taken from Studio 6.0.0.4):
com.approuter.studio.xml.schema.grammar.SchemaResolverTypeSystem loadNewSchema
SEVERE: C:\Program Files\IBM\WebSphere Cast Iron Studio 6.0.0.4 GA 20110928-1725_H2\ShowPartyMasterBOD_2011-05-26_EIMS_2.0.xsd:0: error: sch-props-correct.2: Duplicate global type: ApplicationDetails@http://www.ibm.com/xmlns/eims/2.0/ShowPartyMasterBOD_2011-05-26 (Original global type found in file: )
Throwable occurred: org.apache.xmlbeans.XmlException: C:\Program Files\IBM\WebSphere Cast Iron Studio 6.0.0.4 GA 20110928-1725_H2\ShowPartyMasterBOD_2011-05-26_EIMS_2.0.xsd:0: error: sch-props-correct.2: Duplicate global type: ApplicationDetails@http://www.ibm.com/xmlns/eims/2.0/ShowPartyMasterBOD_2011-05-26 (Original global type found in file: )
at org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler.compile(SchemaTypeSystemCompiler.java:225)
at sun.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.apache.xmlbeans.XmlBeans.compileXmlBeans(XmlBeans.java:667)
at org.apache.xmlbeans.XmlBeans.compileXsd(XmlBeans.java:553)
at com.approuter.studio.xml.schema.grammar.SchemaResolverTypeSystem.loadNewSchema
(SchemaResolverTypeSystem.java:252)
at com.approuter.studio.xml.schema.grammar.SchemaResolverTypeSystem.isNamespaceDefined(SchemaResolverTypeSystem.java:205)

Resolving the problem

The workaround to this issue is to create a dummy WSDL document which contains the two schemas. Put all the files in the same directory and then the WSDL file can be imported into Studio as normal.

For example, imagine you have two schemas, testA.xsd and testB.xsd. The testB.xsd schema in turns imports testA.xsd, as well as some other schemas: testC.xsd, testD.xsd and testE.xsd. These last three schemas do not import any other schemas. All five schemas reside in the same directory. To clarify, here are abbreviated examples of schemas testA.xsd and testB.xsd.

  1. testA.xsd
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:testA="http://www.ibm.com/testA"
    xmlns:testB="http://www.ibm.com/testB"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.ibm.com/testA"
    xmlns="http://www.ibm.com/testA"
    elementFormDefault="qualified">
    <xsd:import namespace="http://www.ibm.com/testB"
    schemaLocation="testB.xsd"/>
    <!-- Rest of schema omitted for brevity -->
    </xsd:schema>

  2. testB.xsd
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:testB="http://www.ibm.com/testB"
    xmlns="http://www.ibm.com/testB"
    xmlns:testA="http://www.ibm.com/testA"
    xmlns:testC="http://www.ibm.com/testC"
    xmlns:testD="http://www.ibm.com/testD"
    xmlns:testE="http://www.ibm.com/testE"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.ibm.com/testB"
    elementFormDefault="qualified">
    <xsd:import namespace="http://www.ibm.com/testC" schemaLocation="testC.xsd"/>
    <xsd:import namespace="http://www.ibm.com/testD" schemaLocation="testD.xsd"/>
    <xsd:import namespace="http://www.ibm.com/testE" schemaLocation="testE.xsd"/>
    <xsd:import namespace="http://www.ibm.com/testA" schemaLocation="testA.xsd"/>
    <!-- Rest of schema omitted for brevity -->
    </xsd:schema>

To wrap the schemas in a WSDL file simply create a new WSDL file in the same directory as the schemas and then paste the contents of the two schemas into the WSDL. In the example above the WSDL file would look like this:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://www.example.com/webservice"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ws="http://www.example.com/webservice">

<xsd:schema xmlns:testA="http://www.ibm.com/testA"
xmlns:testB="http://www.ibm.com/testB"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.ibm.com/testA"
xmlns="http://www.ibm.com/testA"
elementFormDefault="qualified">

<xsd:import namespace="http://www.ibm.com/testB" schemaLocation="testB.xsd"/>

<!-- Rest of schema omitted for brevity -->
</xsd:schema>

<xsd:schema xmlns:testB="http://www.ibm.com/testB"
xmlns="http://www.ibm.com/testB"
xmlns:testA="http://www.ibm.com/testA"
xmlns:testC="http://www.ibm.com/testC"
xmlns:testD="http://www.ibm.com/testD"
xmlns:testE="http://www.ibm.com/testE"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.ibm.com/testB"
elementFormDefault="qualified">

<xsd:import namespace="http://www.ibm.com/testC" schemaLocation="testC.xsd"/>
<xsd:import namespace="http://www.ibm.com/testD" schemaLocation="testD.xsd"/>
<xsd:import namespace="http://www.ibm.com/testE" schemaLocation="testE.xsd"/>
<xsd:import namespace="http://www.ibm.com/testA" schemaLocation="testA.xsd"/>

<!-- Rest of schema omitted for brevity -->
</xsd:schema>

</wsdl:definitions>

Now you should be able to import the new WSDL document into Studio, just like any other WSDL document.

Rate this page:

(0 users)Average rating

Document information


More support for:

WebSphere Cast Iron Cloud integration
Studio

Software version:

5.0.1.1, 5.0.1.2, 5.0.1.3, 5.0.1.4, 5.0.1.5, 5.0.1.6, 5.0.1.7, 6.0.0, 6.0.0.1, 6.0.0.2, 6.0.0.3, 6.0.0.4, 6.1.0.1, 6.1.0.2

Operating system(s):

Windows

Software edition:

Cloud, Physical, Virtual

Reference #:

1573485

Modified date:

2013-02-05

Translate my page

Machine Translation

Content navigation