Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring WS: CommonXsdSchemaCollection fails to resolve XSDs imported with relative path like "../common.xsd" #1450

Open
Skrrytch opened this issue Feb 3, 2025 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@Skrrytch
Copy link

Skrrytch commented Feb 3, 2025

Context: spring-boot-starter-parent 3.4.1
Sample project: https://github.com/Skrrytch/SpringWS-XsdSchemaCollection-Fix

The problem

The sample project provides a SOAP web service via SpringWS. It uses some XSDs organized as follows:

  • /xsd/common.xsd
  • /xsd/order/order.xsd (imports "../common.xsd")
  • /xsd/order/order-webservice.xsd (imports "order.xsd")

Since multiple XSDs are responsible for the final web service, we configure the WsdlDefinition with a CommonXsdSchemaCollection which should resolve all used XSDs.
This works very well as long as no relative import of “common.xsd” is used in our “order.xsd”.

For an import of "../common.xsd" the default classpath uri resolver of CommonXsdSchemaCollection fails with:

java.lang.IllegalArgumentException: The resource path [/../common.xsd] has been normalized to [null] which is not valid

The cause

The problem lies in the following code snippet of CommonXsdSchemaCollection::ClasspathUriResolver:

Resource resources = resourcesLoader.getResource(schemaLocation);
if (resource.exists()) {
   return createInputSource(resource);
} else {
  // Try relative to baseUri ...
}

If schemaLocation is "../common.xsd" then resource.exists() fails with the above exception thrown by the internal call to RequestUtils.normalize("/../common.xsd"). So the following else-statement is never executed.

About this sample project

The current state of this project will throw the exception when starting the application:

mvn clean install
mvn spring-boot:run

We have implemented a workaround in SpringWsConfig:90 (FixedClasspathUriResolver) which can be activated in SpringWsConfig:74.

It solves this problem by catching the exception and executing the else section which then resolves the storage location relatively to the baseUri. This also shows that the existing fallback for relative paths works like a charm!


This is my first bug report here. I couldn't find a similar bug report and hope the information is enough. Otherwise, feel free to ask again!

@snicoll snicoll added the status: waiting-for-triage An issue we've not yet triaged label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants