diff options
author | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-22 14:13:35 +0000 |
---|---|---|
committer | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-22 14:13:35 +0000 |
commit | 517609638e03d901d797c993bf8cacbf99d5b37a (patch) | |
tree | d2d01cde7bc2403e828b3534a21d4e20e0d52ea3 /java/sca/modules/interface-wsdl-xml/src/main | |
parent | c6e6aabeccfad8d564cffb296ab4d5482d493d76 (diff) |
Fix TUSCANY-2418
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@670360 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/interface-wsdl-xml/src/main')
-rw-r--r-- | java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java b/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java index 9581f78980..0004774afa 100644 --- a/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java +++ b/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java @@ -282,6 +282,9 @@ public class WSDLModelResolver implements ModelResolver { // Lookup a definition for the given namespace String namespace = ((WSDLDefinition)unresolved).getNamespace(); + if (namespace == null) { + return modelClass.cast(unresolved); + } List<WSDLDefinition> list = map.get(namespace); WSDLDefinition resolved = aggregate(list); if (resolved != null && !resolved.isUnresolved()) { @@ -352,12 +355,40 @@ public class WSDLModelResolver implements ModelResolver { reader.setFeature("javax.wsdl.importDocuments", true); // FIXME: We need to decide if we should disable the import processing by WSDL4J // reader.setFeature("javax.wsdl.importDocuments", false); - reader.setExtensionRegistry(wsdlExtensionRegistry); + reader.setExtensionRegistry(wsdlExtensionRegistry); // use a custom registry WSDLLocatorImpl locator = new WSDLLocatorImpl(artifactURL, is); Definition definition = reader.readWSDL(locator); wsdlDef.setDefinition(definition); + // If this definition imports any definitions from other namespaces, + // set the correct WSDLDefinition import relationships. + for (Map.Entry<String, List<javax.wsdl.Import>> entry : + ((Map<String, List<javax.wsdl.Import>>)definition.getImports()).entrySet()) { + if (!entry.getKey().equals(definition.getTargetNamespace())) { + WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition(); + wsdlDefinition.setUnresolved(true); + wsdlDefinition.setNamespace(entry.getKey()); + WSDLDefinition resolved = resolveModel(WSDLDefinition.class, wsdlDefinition); + if (!resolved.isUnresolved()) { + for (javax.wsdl.Import imp : entry.getValue()) { + if (resolved.getDefinition().getDocumentBaseURI().equals(imp.getDefinition().getDocumentBaseURI())) { + // this WSDLDefinition contains the imported document + wsdlDef.getImportedDefinitions().add(resolved); + } else { + // this is a facade, so look in its imported definitions + for (WSDLDefinition def : resolved.getImportedDefinitions()) { + if (def.getDefinition().getDocumentBaseURI().equals(imp.getDefinition().getDocumentBaseURI())) { + wsdlDef.getImportedDefinitions().add(def); + break; + } + } + } + } + } + } + } + //Read inline schemas readInlineSchemas(wsdlDef, definition); } catch (WSDLException e) { @@ -427,6 +458,9 @@ public class WSDLModelResolver implements ModelResolver { contribution.getModelResolver().resolveModel(XSDefinition.class, xsDefinition); if (resolved != null && !resolved.isUnresolved()) { if (!wsdlDefinition.getXmlSchemas().contains(resolved)) { + // Don't add resolved because it may be an aggregate that + // contains more than we need. The resolver will have + // set the specific schema we need into unresolved. wsdlDefinition.getXmlSchemas().add(xsDefinition); } } |