Eclipse WSDL Validation Error with Imported Namespaces

10,118

I created the files on my side and I tested with Eclipse Luna 4.4.0 and Web Developer Tools 3.2.5. I put the two .wsdl files in the same generic project, then I imported the .xsd in the XML catalog via the wizard.

When I validated each one of the files and Eclipse didn't find any errors/warnings whatsoever. I did get the error message you cite only when I removed the common.wsdl file from the project, but that is to be expected since it is imported in test.wsdl. I also tried creating a new SoapUI project with test.wsdl (from the Eclipse directory) in SoapUI 5.0.0 and it also didn't complain.

Since I cannot reproduce the error I think that it may very well be a bug of the specific Eclipse version you're using or something wrong with Web Developer Tools. Or it may be some local nonsense that just doesn't pop right away at first sight. Make sure once again that Eclipse actually put all the files physically in the same directory on the filesystem.

See the screenshot of my configuration of Eclipse for you to compare, should you decide to change versions. screenshot

I'd be glad to be able to help you further, but at least I gave you a confirmation that the issue is local. Good luck!


Update 1 after comment 1

Initially, I imported the test.xsd via Import->XML->XML Catalog. Now I moved the .xsd to another filesystem location and removed it from the project (because otherwise it always works). Then, I did it as you proposed (Window->Preferences->XML->XML catalog->User specified entries->Catalog Entry->From filesystem: key type = tried both Namespace name and Schema location and key = http://www.example.org/test). After doing this I get a warning Error reading .xsd file (pointing to the local directory of the project instead of the new location) and multiple errors, one of which is yours.

If I remove the schemaLocation="test.xsd" attribute in common.wsdl and keytype is set to Namespace, then common.wsdl works and doesn't have errors, but test.wsdl says:

The fault element is referencing an undefined message 'serviceFault'. Check that the message name and namespace are correct and that the message has been defined.

I see that common.wsdl has two namespaces with the same namespace name: xs and xsd ("http://www.w3.org/2001/XMLSchema"). Could this be causing the error?

Update 2

I investigated further and I found this wiki page, explaining working with XML catalog and schemas. According to it the behavior is somewhat expected:

Note : If your XML document specificed relative schema locations (e.g. 'foo.xsd' as show below) then an XML Schema can NOT be registered using "foo.xsd" as the Schema Location key. TODO: reference section below that describes why this is the case and how XML Catalog v1.1 provides a way to partially solve this. <xyz:foo xmln:xyz="http://www.example.org/foo/" xsi:schemaLocation="foo.xsd" ...

So it seems they know there is an issue with these relative paths.

Then I tried using full URIs in both the catalog key and in the schemaLocation and it worked with no errors:

http://i.imgur.com/wEXiMrm.jpg

I'll continue looking into this (I found this thread on the Eclipse forums where a similar topic has been discussed) and I'll post an update if something pops up.

Share:
10,118

Related videos on Youtube

maple_shaft
Author by

maple_shaft

I am a software engineer in Pittsburgh, PA with a focus on architecture, design and development of solutions

Updated on September 15, 2022

Comments

  • maple_shaft
    maple_shaft over 1 year

    I received a non inline WSDL file from a services team in my organization, and after adding all of their XSD's to the XML Catalog in Eclipse I am finding their main WSDL file does not validate. It doesn't seem to find the <wsdl:message> element defined in the <wsdl:import>. The validation error is as such:

    The fault element is referencing an undefined message 'serviceFault'. Check that the message name and namespace are correct and that the message has been defined.

    All file paths are relative in the same folder. Here is a small test example that recreates the validation error:

    test.xsd

    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema 
        targetNamespace="http://www.example.org/test" xmlns="http://www.example.org/test"
        elementFormDefault="qualified" attributeFormDefault="unqualified"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:ibmSchExtn="http://www.ibm.com/schema/extensions">
    
        <xsd:complexType name="ServiceFaultType">
            <xsd:sequence>
                <xsd:element name="code" type="xsd:string" />
                <xsd:element name="message" type="xsd:string" />
                <xsd:element minOccurs="0" name="detail" type="xsd:string" />
            </xsd:sequence>
        </xsd:complexType>
    
        <xsd:element ibmSchExtn:docRoot="true" name="serviceFault"
            type="ServiceFaultType" />
    </xsd:schema>
    

    common.wsdl

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        targetNamespace="http://www.example.org/test" xmlns="http://www.example.org/test"
        xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <wsdl:documentation>
            <wsdl:appinfo source="WMQI_APPINFO">
                <MRWSDLAppInfo xmlns="urn:xxx.xxx.xxxbank.com/common/service"
                    imported="true" />
            </wsdl:appinfo>
        </wsdl:documentation>
        <wsdl:types>
            <xs:schema elementFormDefault="qualified">
                <xs:import namespace="http://www.example.org/test"
                    schemaLocation="test.xsd" />
            </xs:schema>
        </wsdl:types>
        <wsdl:message name="serviceFault">
            <wsdl:part element="serviceFault" name="fault" />
        </wsdl:message>
    </wsdl:definitions>
    

    test.wsdl

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        targetNamespace="urn:testservice" xmlns="urn:testservice"
        xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
        xmlns:ns="http://www.example.org/test"
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    
    
        <wsdl:import namespace="http://www.example.org/test" location="common.wsdl"></wsdl:import>
        <wsdl:types>
            <xsd:schema targetNamespace="urn:testservice">
                <xsd:element name="NewOperation">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="in" type="xsd:string" />
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>
                <xsd:element name="NewOperationResponse">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="out" type="xsd:string" />
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>
            </xsd:schema>
        </wsdl:types>
        <wsdl:message name="NewOperationRequest">
            <wsdl:part element="NewOperation" name="parameters" />
        </wsdl:message>
        <wsdl:message name="NewOperationResponse">
            <wsdl:part element="NewOperationResponse" name="parameters" />
        </wsdl:message>
        <wsdl:portType name="test">
            <wsdl:operation name="NewOperation">
                <wsdl:input message="NewOperationRequest" />
                <wsdl:output message="NewOperationResponse" />
                <wsdl:fault message="ns:serviceFault" name="fault" />
            </wsdl:operation>
        </wsdl:portType>
        <wsdl:binding name="testSOAP" type="test">
            <soap:binding style="document"
                transport="http://schemas.xmlsoap.org/soap/http" />
            <wsdl:operation name="NewOperation">
                <soap:operation soapAction="http://www.example.org/test/NewOperation" />
                <wsdl:input>
                    <soap:body use="literal" />
                </wsdl:input>
                <wsdl:output>
                    <soap:body use="literal" />
                </wsdl:output>
            </wsdl:operation>
        </wsdl:binding>
        <wsdl:service name="test">
            <wsdl:port binding="testSOAP" name="testSOAP">
                <soap:address location="http://www.example.org/" />
            </wsdl:port>
        </wsdl:service>
    </wsdl:definitions>
    

    If you add test.xsd to the XML Catalog in Eclipse it demonstrates the validation error. They insist there is nothing wrong with their WSDLs or schemas and JAX-WS seems to generate proxies just fine with wsimport. Furthermore it seems to marshal and unmarshall requests and responses just fine when talking to endpoints.

    Could this be a bug in Eclipse's WSDL validation?

    EDIT: Just a thought even though I still haven't solved the problem. What I think might be going on is that Eclipse is validating the namespace to test.xsd but also in that namespace is common.wsdl which declares its own elements. When Eclipse looks for this common ns:serviceFault in the ns namespace it obviously isnt going to find it in test.xsd. This makes me feel that Eclipse WSDL validation should be a little more intelligent here and identify the WSDL import and include everything in there plus what schema was declared in its XML Catalog. If I am on the mark here, I am still not sure how to solve it. Is there a feature of Eclipse that can actually validate this type of WSDL situation properly?

    • maple_shaft
      maple_shaft about 9 years
      They didn't create the WSDL and then generate things from it. Quite the opposite. They BPEL workflow "developers" (if you can call them that), and they use a crappy IBM workflow designer that automatically generates the garbage you see before you.
  • maple_shaft
    maple_shaft about 9 years
    Thank you for looking into this. Did you remember to add the test.xsd file into the Windows -> Preferences -> XML Catalog? This is where I get the error. If I do not include the location of the test.xsd schema in the XML Catalog then I do not get the error either.
  • Plamen Petrov
    Plamen Petrov about 9 years
    Hey, maple_shaft, I did it as you said, but had to update it in the answer, since it became too long for a comment. Check it out and give me feedback.
  • maple_shaft
    maple_shaft about 9 years
    Hmm, I tried removing the duplicate namespace prefix declaration and I still got the same error. I guess this just doesn't make sense. I guess if this is still a mystery after a few days I might submit a bug to Eclipse and link back to this question. Thanks for your help!
  • Plamen Petrov
    Plamen Petrov about 9 years
    You are welcome, but when you explicitly import the scheme like this <xs:import namespace="example.org/test" schemaLocation="test.xsd" /> doesn't it make sense for Eclipse to look in the local directory first, no matter what has been imported in the XML catalog?
  • Plamen Petrov
    Plamen Petrov about 9 years
    Hey, I found out some more about your issue, you can see the update in my answer. Tell my what you think. I'll keep you posted if I manage to find the "partial workaround" they are talking about to make it work without having a full path.
  • maple_shaft
    maple_shaft about 9 years
    That's great! Thank you! This is exactly what I wanted to know and as far as I can tell using absolute paths in XML Catalog is a sufficient workaround for me to verify WSDL's. I award you the bounty.
  • Plamen Petrov
    Plamen Petrov about 9 years
    I'm glad I helped you! Thank you!