Author: mmillson
Date: 2009-01-06 16:54:28 -0500 (Tue, 06 Jan 2009)
New Revision: 8974
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1550/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
Log:
Fix to enable JBossWSEntityResolver to resolve schemas locally when there is no internet
access [JBPAPP-1550].
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1550/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1550/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2009-01-06
21:03:49 UTC (rev 8973)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP03_JBPAPP-1550/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2009-01-06
21:54:28 UTC (rev 8974)
@@ -75,6 +75,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
import org.jboss.ws.core.soap.Style;
+import org.jboss.ws.core.utils.JBossWSEntityResolver;
import org.jboss.ws.core.utils.ResourceURL;
import org.jboss.ws.metadata.wsdl.Extendable;
import org.jboss.ws.metadata.wsdl.WSDLBinding;
@@ -111,6 +112,7 @@
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
/**
* A helper that translates a WSDL-1.1 object graph into a WSDL-2.0 object graph.
@@ -126,6 +128,7 @@
private static final Logger log = Logger.getLogger(WSDL11Reader.class);
private WSDLDefinitions destWsdl;
+ private JBossWSEntityResolver entityResolver = new JBossWSEntityResolver();
// Maps wsdl message parts to their corresponding element names
private Map<String, QName> messagePartToElementMap = new HashMap<String,
QName>();
@@ -575,7 +578,23 @@
schemaLocationsMap.put(namespace, currLoc);
// Recursively handle schema imports
- Element importedSchema = DOMUtils.parse(currLoc.openStream());
+ Element importedSchema = null;
+ String schema = currLoc.toString();
+ if (entityResolver.getEntityMap().containsKey(schema))
+ {
+ try
+ {
+ importedSchema = DOMUtils.parse(entityResolver.resolveEntity(schema,
schema).getByteStream());
+ }
+ catch (SAXException se)
+ {
+ log.error(se.getMessage(), se);
+ }
+ }
+ if (importedSchema == null)
+ {
+ importedSchema = DOMUtils.parse(currLoc.openStream());
+ }
handleSchemaImports(importedSchema, currLoc);
}
}
Show replies by date