Search code examples
xmlweb-servicesxsdwsdlxerces

How to import a "no-namespace" XML schema into WSDL?


I have an XML schema (called DataQualityCalculationTasks.xsd) that did not declare a target namespace http://www.w3.org/TR/xmlschema-0/#UndeclaredTNS. I imported this XML schema in my WSDL file like this:

<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions 
targetNamespace="http://example.com/myNamespace" 
name="DataQualityServiceService" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

<wsdl:types>
    <xsd:import schemaLocation="DataQualityCalculationTasks.xsd"/>
</wsdl:types>

..................................................................

</wsdl:definitions>

However, I get the following error in eclipse:

src-import.1.2: If the namespace attribute is not present on an element information item then the enclosing schema must have a targetNamespace. The error comes from the XML parser Apache Xerces.

Does anyone know a solution for this?

Thank you!


Solution

  • You could to do it as below:

    <wsdl:types>
        <xsd:schema targetNamespace="urn:tempuri-org">
            <xsd:import schemaLocation="DataQualityCalculationTasks.xsd"/>
        </xsd:schema>
    </wsdl:types>