diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-07-13 17:10:43 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-07-13 17:10:43 +0000 |
commit | 0dd325d979efaaff9c2d1178554b081ea6fb82bf (patch) | |
tree | 5a9eb8d238ff8c9c2dbbad97aaa4d80aa5f68e54 /branches/sca-java-1.x/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java | |
parent | 70ff746f64113f137bdd3ea2af9f77205b5b4e0a (diff) |
Merge the fix for TUSCANY-3141 and xs:import fix from 2.x
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@793628 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java')
-rw-r--r-- | branches/sca-java-1.x/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/branches/sca-java-1.x/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/branches/sca-java-1.x/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java index 7f1d07618f..0399988bd9 100644 --- a/branches/sca-java-1.x/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java +++ b/branches/sca-java-1.x/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java @@ -439,17 +439,30 @@ public class Interface2WSDLGenerator { if (!"".equals(nsURI)) { imp.setAttribute("namespace", nsURI); } - NodeList childNodes = schema.getChildNodes(); + // Scan all xs:import elements to match namespace + NodeList childNodes = schema.getElementsByTagNameNS(SCHEMA_NS, "import"); for (int i = 0; i < childNodes.getLength(); i++) { Node childNode = childNodes.item(i); if (childNode instanceof Element) { - schema.insertBefore(imp, childNode); - imp = null; - break; + String ns = ((Element)childNode).getAttributeNS(SCHEMA_NS, "namespace"); + if (nsURI.equals(ns)) { + // The xs:import with the same namespace has been declared + return; + } } } - if (imp != null) { + // Try to find the first node after the import elements + Node firstNodeAfterImport = null; + if (childNodes.getLength() > 0) { + firstNodeAfterImport = childNodes.item(childNodes.getLength() - 1).getNextSibling(); + } else { + firstNodeAfterImport = schema.getFirstChild(); + } + + if (firstNodeAfterImport == null) { schema.appendChild(imp); + } else { + schema.insertBefore(imp, firstNodeAfterImport); } } @@ -602,8 +615,8 @@ public class Interface2WSDLGenerator { outputMsg.addPart(generateWrapperPart(definition, op, helpers, wrappers, false)); } else { DataType outputType = op.getOutputType(); - outputMsg.addPart(generatePart(definition, outputType, "return")); if (outputType != null) { + outputMsg.addPart(generatePart(definition, outputType, "return")); elements = new ArrayList<ElementInfo>(); ElementInfo element = getElementInfo(outputType.getPhysical(), outputType, null, helpers); elements.add(element); |