Someone else created a JIRA issue regarding this:
http://jira.springframework.org/browse/SWS-362
Someone else created a JIRA issue regarding this:
http://jira.springframework.org/browse/SWS-362
JIRA issue 362
http://jira.springframework.org/browse/SWS-362
was opened by Oliver regarding this specific issue.
This is still broken in 1.4.2.
If Spring WS's CommonsXsdSchemaCollection could inject the XmlSchemaCollection. Then you could call setSchemaResolver() to use a custom URIResolver that was more intelligent.
Here is my solution that seems to work. I am able to resolve schemeas loaded from both the file system and the classloader.
import org.apache.ws.commons.schema.resolver.URIResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.xml.sax.InputSource;
public class DefaultUriResolver implements URIResolver {
private final Logger logger = LoggerFactory.getLogger(DefaultUriResolver.class);
/**
* As for the resolver the publid ID is the target namespace of the
* schema and the schemaLocation is the value of the schema location
* @param namespace
* @param schemaLocation
* @param baseUri
*/
public InputSource resolveEntity(String namespace,
String schemaLocation,
String baseUri){
if (baseUri!=null)
{
try
{
logger.trace("namespace={}, schemaLocation={}, baseUri={}", new Object[] {namespace, schemaLocation, baseUri});
UrlResource uri = new UrlResource(baseUri);
Resource ref = uri.createRelative(schemaLocation);
logger.trace("ref={}", ref);
return new InputSource(ref.getURI().toString());
}
catch (Exception ex)
{
logger.warn("Invalid URI", ex);
throw new RuntimeException(ex);
}
}
return new InputSource(schemaLocation);
}
}