Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
SchemaCollection issues with classpath resources and relative schema imports [SWS-413] #509
This issue is linked to the following thread http://forum.springframework.org/showthread.php?p=176210
I store my schemas in a specific maven project together with the generated sources.
client-messages.xsd import client-types.xsd
In my war project, I configured the Spring-WS config file this way:
<bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
When generating the wsdl, the framework complains that the client-types.xsd is not found.
Would it be possible to enhance the XsdSchemaCollection (or to write a specific org.apache.ws.commons.schema.resolver.URIResolver) which can handle the import nicely ?
Workaround is twofolds:
Affects: 1.5.3, 1.5.4
Referenced from: commits 7464296
2 votes, 5 watchers
Patrick Crocker commented
The fix introduced in spring-ws-1.5.4 only satisfies xsd's found at the root of the classpath. The issue is not resolved with respect to xsd files located in packages.
File messages.xsd uses an import with a relative URL:
This issue could be resolved by attempting to find the imported schema relative to the baseUri value (as shown at http://forum.springframework.org/showpost.php?p=189478&postcount=14 by blackbeltdev).
Additionally, if the CommonsXsdSchemaCollection class was open to having the URIResolver set via dependency injection, users could create their own URIResolver for special cases.
I've attached a modified version of CommonsXsdSchemaCollection that allows DI of the URIResolver (defaults to the private ClasspathUriResolver) and a new ClasspathBaseUriResolver class that merges the ClasspathUriResolver with the baseUri lookup code demonstrated by blackbeltdev on the forum.
Arjen Poutsma commented
Thanks for the code! Wouldn't it be better to use the ClasspahBaseUriResolver as default, rather than the private ClasspathUriResolver one? It seems like its logic s useful in most cases....
I will make the UriResolver settable in any case...