WSDL importing XSD importing another XSD isn't properly resolved for relative
imports
-------------------------------------------------------------------------------------
Key: WSCOMMONS-265
URL: https://issues.apache.org/jira/browse/WSCOMMONS-265
Project: WS-Commons
Issue Type: Bug
Components: XmlSchema
Reporter: Matthieu Riou
I have to following situation (where -> means import and the relative location
of each file is between parentheses):
WSDL (/) -> XSD1(/schema) -> XSD2 (/schema)
I'm using Axis2 which loads the WSDL for me. I also have my own URIResolver.
For the first import, I get the proper baseUri in my resolver (it's the URI of
the WSDL). However for XSD2 the baseUri I'm getting is still the one of the
WSDL instead, which can't be found properly when different relative locations.
Apparently imports within a WSDL document (including transitive ones like we
have here) seem to be associated to a single XmlSchemaCollection. And the
baseUri used for all resolving is the one of the collection. They should either
have a collection per document or associate a baseUri with the document instead
of the collection.
For reference the source of my resolve is the following:
public InputSource resolveEntity(String targetNamespace, String
schemaLocation, String baseUri) {
if (LOG.isDebugEnabled()) {
LOG.debug("resolveEntity: targetNamespace=" + targetNamespace + "
schemaLocation=" + schemaLocation
+ " baseUri=" + baseUri);
}
InputStream is;
try {
URI base = new URI(baseUri);
URI uri = base.resolve(schemaLocation);
is = uri.toURL().openStream();
if (is == null) {
LOG.error("Exception resolving entity: schemaLocation=" +
schemaLocation + " baseUri=" + baseUri);
return null;
}
InputSource source = new InputSource(is);
source.setSystemId(uri.toString());
source.setPublicId(schemaLocation);
return new InputSource(is);
} catch (Exception e) {
LOG.error("Exception resolving entity: schemaLocation=" +
schemaLocation + " baseUri=" + baseUri, e);
return null;
}
}
The stacktrace that I get is:
ERROR - GeronimoLog.error(108) | Exception resolving entity:
schemaLocation=ListeProduit.xsd
baseUri=file:/home/mriou/dev/tools/platform/apache-tomcat-5.5.23/webapps/ode/WEB-INF/processes/TestXSD/BPMN/NewDiagram2-Pool0.wsdl
java.io.FileNotFoundException:
/home/mriou/dev/tools/platform/apache-tomcat-5.5.23/webapps/ode/WEB-INF/processes/TestXSD/BPMN/ListeProduit.xsd
(No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at
sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
at
sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
at java.net.URL.openStream(URL.java:1007)
at
org.apache.ode.axis2.util.Axis2UriResolver.resolveEntity(Axis2UriResolver.java:41)
at
org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1872)
at
org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1902)
at
org.apache.ws.commons.schema.SchemaBuilder.handleInclude(SchemaBuilder.java:1674)
at
org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:169)
at
org.apache.ws.commons.schema.SchemaBuilder.build(SchemaBuilder.java:82)
at
org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:359)
at
org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:304)
at
org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1884)
at
org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:1902)
at
org.apache.ws.commons.schema.SchemaBuilder.handleInclude(SchemaBuilder.java:1674)
at
org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:169)
at
org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:347)
at
org.apache.axis2.description.WSDLToAxisServiceBuilder.getXMLSchema(WSDLToAxisServiceBuilder.java:140)
And I'm going to attach a zip containing the wsdl and the two xsds to
illustrate the situation.
Thanks!
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]