[ 
https://issues.apache.org/jira/browse/CXF-8655?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17488969#comment-17488969
 ] 

Ricardo Martin commented on CXF-8655:
-------------------------------------

After looking into it, this [three 
lines|https://github.com/apache/cxf/blob/cxf-3.5.0/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java#L569-L571]
 are adding the location that appears in the file and later [the other schema 
is not added because it is already present in the 
map|https://github.com/apache/cxf/blob/cxf-3.5.0/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java#L555].
 In those lines the key is only added if not present (so it's optional), but in 
the reproducer it is the other way around, first the optional key is added and 
then the real one is not because the previous is already present. The issue 
CXF-6717 introduced those lines in this 
[commit|https://github.com/apache/cxf/commit/28a092319a9223d93bcbd94abd3e9c0a8a54ac09]
 and my feeling is that it was just added to cover the "urn" catalog type. But:
 * Right now the "urn" URI schema is not valid anymore after CXF-8167 (I don't 
see any way to make it valid).
 * The example in CXF-6717 works using a generated key ({{{}_import1.xsd{}}}) 
even after removing the three lines. I need to manually add "urn" to the valid 
schemas at code level to test it.

I'm going to send a PR with [this 
branch|https://github.com/rmartinc/cxf/commits/CXF-8655-master].  All tests 
pass for me (included the one added for this issue). There is another option to 
solve this, adding the optional keys at the end (for example storing them in 
another map, and only adding them at the end if not present). But I think that 
removing the lines is enough. Please comment in the PR if any change is wanted.

> Incorrect XSD resolution when the file name is the same in different folders
> ----------------------------------------------------------------------------
>
>                 Key: CXF-8655
>                 URL: https://issues.apache.org/jira/browse/CXF-8655
>             Project: CXF
>          Issue Type: Bug
>          Components: Simple Frontend
>    Affects Versions: 3.5.0, 3.3.12, 3.4.5
>            Reporter: Ricardo Martin
>            Priority: Major
>         Attachments: wsdl-test.zip
>
>
> The attached gradle project contains a WSDL file which imports a XSD and it, 
> in turn, imports another two XSD files with the same name but located in 
> different directories. It triggers incorrect resolution of the XSD files. The 
> structure is the following:
> {noformat}
> 1) MyWebservice.wsdl
>    1.1) imports schema/MyWebservice.xsd -> schema/MyWebservice.xsd
>         1.1.1) imports ../../../common/common.xsd -> ../../common/common.xsd
>         1.1.2) imports ../../common/common.xsd -> ../common/common.xsd
>                1.1.2.1) imports ../../common/common.xsd -> 
> ../../common/common.xsd
> {noformat}
> The resulting imports are:
> {noformat}
> 1) http://localhost:8080/wsdl-test/MyWebservice?wsdl (OK)
>    1.1) 
> http://localhost:8080/wsdl-test/MyWebservice?xsd=schema/MyWebservice.xsd (OK)
>         1.1.1) 
> http://localhost:8080/wsdl-test/MyWebservice?xsd=../../common/common.xsd (KO)
>         1.1.2) 
> http://localhost:8080/wsdl-test/MyWebservice?xsd=../common/common.xsd (OK)
>                1.1.2.1) 
> http://localhost:8080/wsdl-test/MyWebservice?xsd=../../common/common.xsd (KO)
> {noformat}
>    
> The URL 
> {{[http://localhost:8080/wsdl-test/MyWebservice?xsd=../../common/common.xsd]}}
>  in 1.1.1 returns invalid content. The content is the file in 1.1.2 (not 
> 1.1.1) and besides the contained import is not rewritten in its location.
>  
> h3. Steps To reproduce:
>  * Download attached maven project.
> {code}
> unzip wsdl-test.zip
> cd wsdl-test/
> mvn clean package
> mvn jetty:run
> {code}
> * Go to the wsdl {{http://localhost:8080/wsdl-test/MyWebservice?wsdl}} and 
> follow imports until 
> {{http://localhost:8080/wsdl-test/MyWebservice?xsd=../../common/common.xsd}} 
> and check the received output is incorrect.
> * You can also execute the client while the jetty is running with:
> {code}
> mvn exec:java
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to