Author: thomas.diesler(a)jboss.com
Date: 2007-10-17 06:51:32 -0400 (Wed, 17 Oct 2007)
New Revision: 4781
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
Log:
[JBWS-1798] JBossWS cannot find local schema with relative urls
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2007-10-17
08:56:48 UTC (rev 4780)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2007-10-17
10:51:32 UTC (rev 4781)
@@ -102,7 +102,7 @@
/**
* Modify the location of wsdl and schema imports
*/
- private void modifyAddressReferences(URL reqURL, String wsdlHost, String resPath,
Element element) throws MalformedURLException
+ private void modifyAddressReferences(URL reqURL, String wsdlHost, String resPath,
Element element) throws IOException
{
// map wsdl definition imports
NodeList nlist = element.getChildNodes();
@@ -130,8 +130,30 @@
String newResourcePath = orgLocation;
if (resPath != null && resPath.indexOf("/") >
0)
- newResourcePath = resPath.substring(0,
resPath.lastIndexOf("/") + 1) + orgLocation;
+ {
+ String resParent = resPath.substring(0,
resPath.lastIndexOf("/"));
+ while (orgLocation.startsWith("../") &&
resParent != null)
+ {
+ if (resParent.indexOf("/") > 0)
+ {
+ resParent = resParent.substring(0,
resParent.lastIndexOf("/"));
+ orgLocation = orgLocation.substring(3);
+ newResourcePath = resParent + "/" + orgLocation;
+ }
+ else
+ {
+ orgLocation = orgLocation.substring(3);
+ newResourcePath = orgLocation;
+ resParent = null;
+ }
+ }
+ }
+ while (newResourcePath.startsWith("./"))
+ {
+ newResourcePath = newResourcePath.substring(2);
+ }
+
String reqPath = reqURL.getPath();
String completeHost = wsdlHost;
Modified: stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2007-10-17
08:56:48 UTC (rev 4780)
+++ stack/native/trunk/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2007-10-17
10:51:32 UTC (rev 4781)
@@ -553,9 +553,9 @@
return tmpFile != null ? tmpFile.toURL() : null;
}
- private void handleSchemaImports(Element schemaEl, URL wsdlLoc) throws
MalformedURLException, WSDLException
+ private void handleSchemaImports(Element schemaEl, URL parentURL) throws
WSDLException, IOException
{
- if (wsdlLoc == null)
+ if (parentURL == null)
throw new IllegalArgumentException("Cannot process import, parent location
not set");
Iterator it = DOMUtils.getChildElements(schemaEl, new
QName(Constants.NS_SCHEMA_XSD, "import"));
@@ -570,8 +570,15 @@
// Skip, let the entity resolver resolve these
if (namespace != null && schemaLocation != null)
{
- URL currLoc = getLocationURL(wsdlLoc, schemaLocation);
- schemaLocationsMap.put(namespace, currLoc);
+ URL currLoc = getLocationURL(parentURL, schemaLocation);
+ if (schemaLocationsMap.get(namespace) == null)
+ {
+ schemaLocationsMap.put(namespace, currLoc);
+
+ // Recursively handle schema imports
+ Element importedSchema = DOMUtils.parse(currLoc.openStream());
+ handleSchemaImports(importedSchema, currLoc);
+ }
}
else
{