Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-5600

Inner schema includes are not resolved with their absolute paths

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • jboss-fuse-6.3
    • jboss-fuse-6.2.1
    • CXF
    • None
    • % %
    • Hide
      Show
      Attached is the project Start Fuse 6.2.1 or 6.2.0 on debug mode, ./fuse debug Deploy the jar. curl http://localhost:8181/cxf/absolute?xsd=../greeting.xsd

      The project structure is like this,

      ├── pom.xml
      ├── Readme.md
      ├── src
      │   ├── main
      │   │   ├── java
      │   │   │   └── com
      │   │   │   └── redhat
      │   │   │   └── GreetingServiceImpl.java
      │   │   └── resources
      │   │   └── META-INF
      │   │   ├── greeting.xsd
      │   │   ├── jax-ws-catalog.xml
      │   │   ├── schema.xsd
      │   │   ├── spring
      │   │   │   └── context.xml
      │   │   └── wsdl
      │   │   └── greeting.wsdl

      • Here the greeting.wsdl, 'imports' the 'greeting.xsd'.
      • 'greeting.xsd' includes 'schema.xsd'.

      Testing this on Fuse 6.1.x, the deployed wsdl contract seems to be publishing the inner xsd, schema.xsd with the absolute URI,

      for example,

      <?xml version='1.0' encoding='UTF-8'?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:types="http://ws.samples.redhat.com/types" targetNamespace="http://ws.samples.redhat.com/types" version="1.0">
      
        <xs:include schemaLocation="http://localhost:8181/cxf/absolute?xsd=../schema.xsd"/>
      

      In Fuse 6.2.x, we only get the relative path of the xsd import,

      <?xml version='1.0' encoding='UTF-8'?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:types="http://ws.samples.redhat.com/types" targetNamespace="http://ws.samples.redhat.com/types" version="1.0">
      
        <xs:include schemaLocation="schema.xsd"/>
      
      • The mapping URI for the schemaLocation Reference in WSDLGetUtils is evaluated as 'null'.
      elementList = DOMUtils.findAllElementsByTagNameNS(doc.getDocumentElement(),
                                                                    "http://www.w3.org/2001/XMLSchema",
                                                                    "include");
                  for (Element el : elementList) {
                      String sl = el.getAttribute("schemaLocation");
                      sl = mapUri(base, smp, sl, xsd);
                      if (sl != null) {
                          el.setAttribute("schemaLocation", sl);
                      }
                  }
      

      'sl = mapUri(base, smp, sl, xsd);' above is evaluated as 'null'.

      This is the relevant code,

      protected String mapUri(String base, Map<String, SchemaReference> smp, String loc, String xsd)
              throws UnsupportedEncodingException {
              String key = loc;
              try {
                  boolean absoluteLocUri = new URI(loc).isAbsolute();
                  if (!absoluteLocUri && xsd != null) {
                      key = new URI(xsd).resolve(loc).toString();
                  }
                  if (!absoluteLocUri && xsd == null) {
                      key = new URI(".").resolve(loc).toString();
                  }
              } catch (URISyntaxException e) {
                 //ignore
              }
              SchemaReference ref = smp.get(URLDecoder.decode(key, "utf-8"));
              if (ref != null) {
                  return base + "?xsd=" + key.replace(" ", "%20");
              }
              return null;
          }
      
      

      This is where the problem lies,

      >>

      SchemaReference ref = smp.get(URLDecoder.decode(key, "utf-8"));
              if (ref != null) {
                  return base + "?xsd=" + key.replace(" ", "%20");
              }
      

      the 'ref' is evaluated as 'null', and the condition on the 'if' is never evaluated.

      This seems to be working on Fuse 6.3, which has CXF version 3.1.5.

            yfang@redhat.com Freeman(Yue) Fang
            rhn-support-vgohel Viral Gohel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: