title: Eclipse WSDL Validation Error with Imported Namespaces
body: <p>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 <code>&lt;wsdl:message&gt;</code> element defined in the <code>&lt;wsdl:import&gt;</code>.  The validation error is as such:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>All file paths are relative in the same folder.  Here is a small test example that recreates the validation error:</p>
  
  <p><strong>test.xsd</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
  
      &lt;xsd:complexType name="ServiceFaultType"&gt;
          &lt;xsd:sequence&gt;
              &lt;xsd:element name="code" type="xsd:string" /&gt;
              &lt;xsd:element name="message" type="xsd:string" /&gt;
              &lt;xsd:element minOccurs="0" name="detail" type="xsd:string" /&gt;
          &lt;/xsd:sequence&gt;
      &lt;/xsd:complexType&gt;
  
      &lt;xsd:element ibmSchExtn:docRoot="true" name="serviceFault"
          type="ServiceFaultType" /&gt;
  &lt;/xsd:schema&gt;
  </code></pre>
  
  <p><strong>common.wsdl</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;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"&gt;
      &lt;wsdl:documentation&gt;
          &lt;wsdl:appinfo source="WMQI_APPINFO"&gt;
              &lt;MRWSDLAppInfo xmlns="urn:xxx.xxx.xxxbank.com/common/service"
                  imported="true" /&gt;
          &lt;/wsdl:appinfo&gt;
      &lt;/wsdl:documentation&gt;
      &lt;wsdl:types&gt;
          &lt;xs:schema elementFormDefault="qualified"&gt;
              &lt;xs:import namespace="http://www.example.org/test"
                  schemaLocation="test.xsd" /&gt;
          &lt;/xs:schema&gt;
      &lt;/wsdl:types&gt;
      &lt;wsdl:message name="serviceFault"&gt;
          &lt;wsdl:part element="serviceFault" name="fault" /&gt;
      &lt;/wsdl:message&gt;
  &lt;/wsdl:definitions&gt;
  </code></pre>
  
  <p><strong>test.wsdl</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;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"&gt;
  
  
      &lt;wsdl:import namespace="http://www.example.org/test" location="common.wsdl"&gt;&lt;/wsdl:import&gt;
      &lt;wsdl:types&gt;
          &lt;xsd:schema targetNamespace="urn:testservice"&gt;
              &lt;xsd:element name="NewOperation"&gt;
                  &lt;xsd:complexType&gt;
                      &lt;xsd:sequence&gt;
                          &lt;xsd:element name="in" type="xsd:string" /&gt;
                      &lt;/xsd:sequence&gt;
                  &lt;/xsd:complexType&gt;
              &lt;/xsd:element&gt;
              &lt;xsd:element name="NewOperationResponse"&gt;
                  &lt;xsd:complexType&gt;
                      &lt;xsd:sequence&gt;
                          &lt;xsd:element name="out" type="xsd:string" /&gt;
                      &lt;/xsd:sequence&gt;
                  &lt;/xsd:complexType&gt;
              &lt;/xsd:element&gt;
          &lt;/xsd:schema&gt;
      &lt;/wsdl:types&gt;
      &lt;wsdl:message name="NewOperationRequest"&gt;
          &lt;wsdl:part element="NewOperation" name="parameters" /&gt;
      &lt;/wsdl:message&gt;
      &lt;wsdl:message name="NewOperationResponse"&gt;
          &lt;wsdl:part element="NewOperationResponse" name="parameters" /&gt;
      &lt;/wsdl:message&gt;
      &lt;wsdl:portType name="test"&gt;
          &lt;wsdl:operation name="NewOperation"&gt;
              &lt;wsdl:input message="NewOperationRequest" /&gt;
              &lt;wsdl:output message="NewOperationResponse" /&gt;
              &lt;wsdl:fault message="ns:serviceFault" name="fault" /&gt;
          &lt;/wsdl:operation&gt;
      &lt;/wsdl:portType&gt;
      &lt;wsdl:binding name="testSOAP" type="test"&gt;
          &lt;soap:binding style="document"
              transport="http://schemas.xmlsoap.org/soap/http" /&gt;
          &lt;wsdl:operation name="NewOperation"&gt;
              &lt;soap:operation soapAction="http://www.example.org/test/NewOperation" /&gt;
              &lt;wsdl:input&gt;
                  &lt;soap:body use="literal" /&gt;
              &lt;/wsdl:input&gt;
              &lt;wsdl:output&gt;
                  &lt;soap:body use="literal" /&gt;
              &lt;/wsdl:output&gt;
          &lt;/wsdl:operation&gt;
      &lt;/wsdl:binding&gt;
      &lt;wsdl:service name="test"&gt;
          &lt;wsdl:port binding="testSOAP" name="testSOAP"&gt;
              &lt;soap:address location="http://www.example.org/" /&gt;
          &lt;/wsdl:port&gt;
      &lt;/wsdl:service&gt;
  &lt;/wsdl:definitions&gt;
  </code></pre>
  
  <p>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.</p>
  
  <p>Could this be a bug in Eclipse's WSDL validation?</p>
  
  <p><strong>EDIT:</strong> 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 <code>test.xsd</code> but also in that namespace is <code>common.wsdl</code> which declares its own elements.  When Eclipse looks for this common <code>ns:serviceFault</code> in the ns namespace it obviously isnt going to find it in <code>test.xsd</code>.  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?</p>