diff options
author | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2011-04-13 10:32:15 +0000 |
---|---|---|
committer | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2011-04-13 10:32:15 +0000 |
commit | 0548f00a2d2a342026d514f4f69a98a398673da8 (patch) | |
tree | 612fec2c7a86d30cf69b334dfb717f131746ee52 /sca-java-1.x/trunk | |
parent | 022b1049dc7c384984ed673374c3ca643d52ea79 (diff) |
TUSCANY-3859: Update "no namespace" type references in xs:extension schema elements
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1091732 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/trunk')
7 files changed, 150 insertions, 31 deletions
diff --git a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/BaseClass.java b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/BaseClass.java new file mode 100644 index 0000000000..b9b7d6eb65 --- /dev/null +++ b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/BaseClass.java @@ -0,0 +1,46 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package wsdlgen.verify;
+
+import java.io.Serializable;
+
+public class BaseClass implements Serializable {
+ private static final long serialVersionUID = -4086312879555658070L;
+
+ private long id;
+
+ private String commentair;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getCommentair() {
+ return commentair;
+ }
+
+ public void setCommentair(String commentair) {
+ this.commentair = commentair;
+ }
+}
diff --git a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/DataTypes.java b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/DataTypes.java index 68b87d3947..5715b24ebb 100644 --- a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/DataTypes.java +++ b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/DataTypes.java @@ -50,6 +50,8 @@ public interface DataTypes { void testByteArray(byte[] byteArray);
+ void testBaseExtension(ExtClass ext);
+
void testException() throws Exception;
DataObject testDynamicSDO();
diff --git a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/ExtClass.java b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/ExtClass.java new file mode 100644 index 0000000000..fe6f6fe97c --- /dev/null +++ b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/ExtClass.java @@ -0,0 +1,34 @@ +/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package wsdlgen.verify;
+
+public class ExtClass extends BaseClass {
+ private static final long serialVersionUID = 7076974968473202208L;
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/impl/DataTypesImpl.java b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/impl/DataTypesImpl.java index 55e59947ad..9d9cf8ca73 100644 --- a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/impl/DataTypesImpl.java +++ b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/impl/DataTypesImpl.java @@ -23,8 +23,10 @@ import java.util.List; import javax.jws.WebParam;
import javax.jws.soap.SOAPBinding;
import commonj.sdo.DataObject;
+import wsdlgen.verify.BaseClass;
import wsdlgen.verify.ComplexNumber;
import wsdlgen.verify.DataTypes;
+import wsdlgen.verify.ExtClass;
public class DataTypesImpl implements DataTypes {
@@ -62,6 +64,9 @@ public class DataTypesImpl implements DataTypes { public void testByteArray(byte[] byteArray) {
}
+ public void testBaseExtension(ExtClass ext) {
+ }
+
public void testException() throws Exception {
}
diff --git a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/BaseFramework.java b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/BaseFramework.java index 06b6bb77b4..e8abc956cf 100644 --- a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/BaseFramework.java +++ b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/BaseFramework.java @@ -199,6 +199,16 @@ public class BaseFramework { return (Element)childNodes.item(0);
}
+ protected Element extensionElement(Element complexType) {
+ // find xs:complexContent child element
+ NodeList childNodes = complexType.getElementsByTagNameNS(SCHEMA_NS, "complexContent");
+ Element complexContent = (Element)childNodes.item(0);
+
+ // find first xs:extension child element
+ childNodes = complexContent.getElementsByTagNameNS(SCHEMA_NS, "extension");
+ return (Element)childNodes.item(0);
+ }
+
private static void readWSDL(String serviceName) throws Exception {
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose",false);
diff --git a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/DataTypesTestCase.java b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/DataTypesTestCase.java index 9071edb986..b6dbeecda5 100644 --- a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/DataTypesTestCase.java +++ b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/DataTypesTestCase.java @@ -107,6 +107,13 @@ public class DataTypesTestCase extends BaseFramework { }
@Test
+ public void testBaseExtension() throws Exception {
+ String paramType = parameterType("testBaseExtension");
+ assertEquals("tns:extClass", paramType);
+ assertEquals("tns:baseClass", extensionElement(typeDefinition(paramType)).getAttribute("base"));
+ }
+
+ @Test
public void testException() throws Exception {
assertEquals("xs:string", faultType("testException", "Exception"));
}
diff --git a/sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java index 00a767c089..ecd11dd452 100644 --- a/sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java +++ b/sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java @@ -728,41 +728,56 @@ public class Interface2WSDLGenerator { _import.getParentNode().removeChild(_import); } - // look for any type attributes that refer to the - // node being merged - NodeList elements = refSchema.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema","element"); - for (int k = 0; k < elements.getLength(); k++){ - Element element = (Element) elements.item(k); - if (element != null && element.getAttributes() != null) { - Node type = element.getAttributes().getNamedItem("type"); - - if (type != null && - type.getNodeValue().equals(typeName)){ - if (xsDef.getNamespace().equals(defaultNamespace)){ - // double check that there is a "tns" namespace shortname specified - String tnsNamespace = refSchema.getDocumentElement().getAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns"); - - if (tnsNamespace == null || tnsNamespace.length() == 0) { - refSchema.getDocumentElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns", defaultNamespace); - } - - // just add "tns" in front of the type name as - // we have merged the type into this schema - type.setNodeValue("tns:" + type.getNodeValue()); - } else { - // add a namespace - refSchema.getDocumentElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:__nnns", defaultNamespace); - - // prefix the type name with the namespace - type.setNodeValue("__nnns:" + type.getNodeValue()); - } - } - } - } + // TUSCANY-3859: Look for any attributes that refer to the node being merged + fixUpNoNamespaceAttributes("element", "type", xsDef, typeName, defaultNamespace); + fixUpNoNamespaceAttributes("extension", "base", xsDef, typeName, defaultNamespace); } } } + /** + * TUSCANY-3859 + * Correct any schema attributes that used to point to types in the no namespace schema + * + * @param elementName + * @param attributeName + * @param xsDef + * @param defaultNamespace + */ + private void fixUpNoNamespaceAttributes(String elementName, String attributeName, + XSDefinition xsDef, String typeName, String defaultNamespace) { + Document refSchema = xsDef.getDocument(); + NodeList elements = refSchema.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", elementName); + for (int k = 0; k < elements.getLength(); k++){ + Element element = (Element) elements.item(k); + if (element != null && element.getAttributes() != null) { + Node type = element.getAttributes().getNamedItem(attributeName); + + if (type != null && + type.getNodeValue().equals(typeName)){ + if (xsDef.getNamespace().equals(defaultNamespace)){ + // double check that there is a "tns" namespace shortname specified + String tnsNamespace = refSchema.getDocumentElement().getAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns"); + + if (tnsNamespace == null || tnsNamespace.length() == 0) { + refSchema.getDocumentElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns", defaultNamespace); + } + + // just add "tns" in front of the type name as + // we have merged the type into this schema + type.setNodeValue("tns:" + type.getNodeValue()); + } else { + // add a namespace + refSchema.getDocumentElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:__nnns", defaultNamespace); + + // prefix the type name with the namespace + type.setNodeValue("__nnns:" + type.getNodeValue()); + } + } + } + } + } + /* * Just used when debugging DOM problems */ |