Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-6034

Wrong schemaLocation if jax-ws-catalog is used

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.1
    • 3.0.3, 2.7.14
    • Simple Frontend
    • None
    • Unknown

    Description

      When

      • using a WSDL-first approach,
      • defining endpoints so that your (not generated) WSDL is provided,
      • using jax-ws-catalog

      the WSDL given out to the client is sometimes incorrect.

      Specifically, having entries in jax-ws-catalog like these

          <public publicId="http://test.com/main/schema" uri="../main/schema.xsd" />
          <system systemId="http://test.com/main/schema" uri="../main/schema.xsd" />
      
          <public publicId="http://test.com/auxiliary/schema" uri="../auxiliary/auxiliary.xsd" />
          <system systemId="http://test.com/auxiliary/schema" uri="../auxiliary/auxiliary.xsd" />
      

      And having XSD imports in your types section of WSDL like these:

      <xs:schema targetNamespace="http://test.com/main/customer-service" ...>
          <!-- this fails -->
          <xsd:import namespace="http://test.com/main/schema" schemaLocation="http://test.com/main/schema"/>
          <!-- this works -->
          <xsd:import namespace="http://test.com/auxiliary/schema" schemaLocation="http://test.com/auxiliary/schema"/>
      </xs:schema>
      

      The resulting WSDL is like this (showing only the relevant part):

      <xs:schema targetNamespace="http://test.com/main/customer-service" ...>
          <!-- this fails -->
          <xsd:import namespace="http://test.com/main/schema" schemaLocation="http://test.com/main/schema"/>
          <!-- this works -->
          <xsd:import namespace="http://test.com/auxiliary/schema" schemaLocation="http://localhost:9090/CustomerServicePort?xsd=http://test.com/auxiliary/schema"/
      </xs:schema>
      

      (note the wrong schemaLocation attribute in the first import)

      The problem occurs when the URI of the resource being imported is the same as (except for its last segment) the URI of the WSDL itself. In this case, *http://test.com/main/*schema vs. *http://test.com/main/*customer-service.

      I was able to fix this preliminarily by disabling "optimization" used in WSDLGetUtils.findSchemaLocation, namely this code:

              if (docBase != null && imp.getReferencedSchema() != null) {
                  try {
                      String baseURI = URLDecoder.decode(UrlUtils.getStem(docBase), "utf-8");
                      String importURI = URLDecoder.decode(imp.getReferencedSchema().getDocumentBaseURI(), "utf-8");
                      if (importURI.contains(baseURI)) {
                          schemaLocationURI = importURI.substring(baseURI.length() + 1);
                      }
                  } catch (Exception e) {
                      //ignore
                  }
      
              }
      

      However, I'm sure this is in fact a workaround; there should exist a cleaner solution.

      Attachments

        1. wsdl_first.zip
          8 kB
          Pavol Mederly

        Activity

          People

            dkulp Daniel Kulp
            mederly Pavol Mederly
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: