This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 3.5.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git
commit c22923ce776efc203ecbae8df2228c6b064fd1f7 Author: rmartinc <[email protected]> AuthorDate: Wed Mar 16 01:10:04 2022 +0100 [CXF-8655] Incorrect XSD resolution when the file name is the same in different folders (#904) --- .../java/org/apache/cxf/frontend/WSDLGetUtils.java | 4 ++- .../apache/cxf/systest/jaxws/OASISCatalogTest.java | 27 ++++++++++++++++++ .../src/main/resources/wsdl/others/common.xsd | 27 ++++++++++++++++++ .../src/main/resources/wsdl/others/d/common.xsd | 30 ++++++++++++++++++++ .../src/main/resources/wsdl/others/d/shared.xsd | 32 ++++++++++++++++++++++ .../wsdl/others/hello_world_messages_catalog.wsdl | 5 ++++ 6 files changed, 124 insertions(+), 1 deletion(-) diff --git a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java index 958b118..e724e4a 100644 --- a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java +++ b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java @@ -552,7 +552,9 @@ public class WSDLGetUtils { start), e); } - if (!doneSchemas.containsKey(decodedStart)) { + final SchemaReference doneSchema = doneSchemas.get(decodedStart); + if (doneSchema == null || !doneSchema.getSchemaLocationURI().equals( + schemaReference.getSchemaLocationURI())) { String resolvedSchemaLocation = resolveWithCatalogs(catalogs, start, base); if (resolvedSchemaLocation == null) { resolvedSchemaLocation = diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java index 1ba4cf8..8596bd6 100644 --- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java +++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java @@ -62,6 +62,33 @@ public class OASISCatalogTest { "SoapPort"); @Test + public void testWSDLPublishSamePath() throws Exception { + Endpoint ep = Endpoint.publish("http://localhost:" + PORT + "/SoapContext/SoapPort", + new GreeterImpl()); + + try { + String result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort?" + + "wsdl=http://apache.org/hello_world/types2/hello_world_messages_catalog.wsdl"); + assertTrue(result, result.contains("xsd=http://apache.org/hello_world/types2/d/shared.xsd")); + + result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort?" + + "xsd=http://apache.org/hello_world/types2/d/shared.xsd"); + assertTrue(result, result.contains("xsd=http://apache.org/hello_world/types2/common.xsd")); + assertTrue(result, result.contains("xsd=http://apache.org/hello_world/types2/d/common.xsd")); + + result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort?" + + "xsd=http://apache.org/hello_world/types2/common.xsd"); + assertFalse(result, result.contains("schemaLocation")); + + result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort?" + + "xsd=http://apache.org/hello_world/types2/d/common.xsd"); + assertTrue(result, result.contains("xsd=http://apache.org/hello_world/types2/common.xsd")); + } finally { + ep.stop(); + } + } + + @Test public void testWSDLPublishWithCatalogs() throws Exception { Endpoint ep = Endpoint.publish("http://localhost:" + PORT + "/SoapContext/SoapPort", new GreeterImpl()); diff --git a/testutils/src/main/resources/wsdl/others/common.xsd b/testutils/src/main/resources/wsdl/others/common.xsd new file mode 100644 index 0000000..a3688d7 --- /dev/null +++ b/testutils/src/main/resources/wsdl/others/common.xsd @@ -0,0 +1,27 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://apache.org/hello_world/common" + elementFormDefault="qualified"> + + <xsd:element name="common"> + <xsd:complexType/> + </xsd:element> +</xsd:schema> diff --git a/testutils/src/main/resources/wsdl/others/d/common.xsd b/testutils/src/main/resources/wsdl/others/d/common.xsd new file mode 100644 index 0000000..a778a0f --- /dev/null +++ b/testutils/src/main/resources/wsdl/others/d/common.xsd @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://apache.org/hello_world/d/common" + elementFormDefault="qualified"> + + <xsd:import namespace="http://apache.org/hello_world/common" + schemaLocation="../common.xsd"/> + + <xsd:element name="dcommon"> + <xsd:complexType/> + </xsd:element> +</xsd:schema> diff --git a/testutils/src/main/resources/wsdl/others/d/shared.xsd b/testutils/src/main/resources/wsdl/others/d/shared.xsd new file mode 100644 index 0000000..a0772d5 --- /dev/null +++ b/testutils/src/main/resources/wsdl/others/d/shared.xsd @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://apache.org/hello_world/d/shared" + elementFormDefault="qualified"> + + <xsd:import namespace="http://apache.org/hello_world/common" + schemaLocation="../common.xsd"/> + <xsd:import namespace="http://apache.org/hello_world/d/common" + schemaLocation="common.xsd"/> + + <xsd:element name="dshared"> + <xsd:complexType/> + </xsd:element> +</xsd:schema> diff --git a/testutils/src/main/resources/wsdl/others/hello_world_messages_catalog.wsdl b/testutils/src/main/resources/wsdl/others/hello_world_messages_catalog.wsdl index 8e5290b..f84ad06 100644 --- a/testutils/src/main/resources/wsdl/others/hello_world_messages_catalog.wsdl +++ b/testutils/src/main/resources/wsdl/others/hello_world_messages_catalog.wsdl @@ -32,6 +32,11 @@ <xsd:import namespace="http://apache.org/hello_world/schemas-in-separate-dir" schemaLocation="http://apache.org/hello_world/schemas-in-separate-dir-non-cp/another-schema.xsd"/> </schema> + <schema targetNamespace="http://apache.org/hello_world/types2" + xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> + <xsd:import namespace="http://apache.org/hello_world/d/shared" + schemaLocation="d/shared.xsd"/> + </schema> </wsdl:types> <wsdl:message name="sayHiRequest"> <wsdl:part name="in" element="x1:sayHi"/>
