diff options
Diffstat (limited to '')
6 files changed, 454 insertions, 0 deletions
diff --git a/sca-java-1.x/trunk/itest/wsdlgen-verify/pom.xml b/sca-java-1.x/trunk/itest/wsdlgen-verify/pom.xml new file mode 100644 index 0000000000..e892dc1aef --- /dev/null +++ b/sca-java-1.x/trunk/itest/wsdlgen-verify/pom.xml @@ -0,0 +1,155 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-wsdlgen-verify</artifactId>
+ <name>Apache Tuscany SCA iTest runtime WSDL generation verification</name>
+
+ <repositories>
+ <repository>
+ <id>apache.incubator</id>
+ <url>http://people.apache.org/repo/m2-incubating-repository</url>
+ </repository>
+ <repository>
+ <id>java.net2</id>
+ <name>java.net Maven 2.x Repository</name>
+ <url>http://download.java.net/maven/2</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sdo</groupId>
+ <artifactId>tuscany-sdo-api-r2.1</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>1.7-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.xml.soap</groupId>
+ <artifactId>saaj-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ <artifactItem>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ <type>jar</type>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Djava.endorsed.dirs=target/endorsed</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/GetDataServiceWithoutException.java b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/GetDataServiceWithoutException.java new file mode 100644 index 0000000000..35fab34c3f --- /dev/null +++ b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/GetDataServiceWithoutException.java @@ -0,0 +1,41 @@ +/*
+ * 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 commonj.sdo.DataObject;
+import java.util.List;
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public abstract interface GetDataServiceWithoutException
+{
+ public abstract byte[] getMessage(String paramString);
+
+ public abstract List<byte[]> getMessageList(String paramString);
+
+ public abstract DataObject getMessageSDO(String paramString);
+
+ public abstract List<DataObject> getMessageListSDOList(String paramString);
+
+ public abstract DataObject[] getMessageListSDOArr(String paramString);
+
+ public abstract DataObject getMessageListSDOinSDO(String paramString);
+}
+
diff --git a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/impl/GetDataServiceWithoutExceptionImpl.java b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/impl/GetDataServiceWithoutExceptionImpl.java new file mode 100644 index 0000000000..2ad3e231ed --- /dev/null +++ b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/java/wsdlgen/verify/impl/GetDataServiceWithoutExceptionImpl.java @@ -0,0 +1,52 @@ +/*
+ * 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.impl;
+
+import commonj.sdo.DataObject;
+import java.util.List;
+import wsdlgen.verify.GetDataServiceWithoutException;
+
+public class GetDataServiceWithoutExceptionImpl implements GetDataServiceWithoutException {
+
+ public byte[] getMessage(String paramString) {
+ return null;
+ }
+
+ public List<byte[]> getMessageList(String paramString) {
+ return null;
+ }
+
+ public DataObject getMessageSDO(String paramString) {
+ return null;
+ }
+
+ public List<DataObject> getMessageListSDOList(String paramString) {
+ return null;
+ }
+
+ public DataObject[] getMessageListSDOArr(String paramString) {
+ return null;
+ }
+
+ public DataObject getMessageListSDOinSDO(String paramString) {
+ return null;
+ }
+}
+
diff --git a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/resources/dynamic-sdo.composite b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/resources/dynamic-sdo.composite new file mode 100644 index 0000000000..4dd25b46d3 --- /dev/null +++ b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/main/resources/dynamic-sdo.composite @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + targetNamespace="http://verify.wsdlgen/" + name="DynamicSDO"> + + <component name="DataService"> + <implementation.java class="wsdlgen.verify.impl.GetDataServiceWithoutExceptionImpl" /> + <service name="GetDataServiceWithoutException"> + <binding.ws uri="http://localhost:8085/DataService" /> + </service> + </component> + +</composite> diff --git a/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/DynamicSDOTestCase.java b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/DynamicSDOTestCase.java new file mode 100644 index 0000000000..3445d2f06b --- /dev/null +++ b/sca-java-1.x/trunk/itest/wsdlgen-verify/src/test/java/wsdlgen/verify/DynamicSDOTestCase.java @@ -0,0 +1,172 @@ +/*
+ * 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.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.Message;
+import javax.wsdl.Part;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.Types;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import junit.framework.TestCase;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ * Test ?wsdl works and that the returned WSDL has the correct endpoint
+ *
+ * @version $Rev: 814373 $ $Date: 2009-09-13 19:06:29 +0100 (Sun, 13 Sep 2009) $
+ */
+public class DynamicSDOTestCase extends TestCase {
+ private static final String SCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
+ private static final String SCHEMA_NAME = "schema";
+ private static final QName SCHEMA_QNAME = new QName(SCHEMA_NS, SCHEMA_NAME);
+
+ private SCADomain domain;
+
+ /**
+ * Tests ?wsdl works and produces xs:anyType for commonj.sdo.DataObject
+ */
+ public void testDynamicSDO() throws Exception {
+ InputStream inp = new URL("http://localhost:8085/DataService?wsdl").openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(inp));
+ String line;
+ while((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ br.close();
+
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose",false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments",true);
+
+ Definition definition = wsdlReader.readWSDL("http://localhost:8085/DataService?wsdl");
+ assertNotNull(definition);
+ Service service = definition.getService(new QName("http://verify.wsdlgen/",
+ "GetDataServiceWithoutExceptionService"));
+ Port port = service.getPort("GetDataServiceWithoutExceptionPort");
+ Binding binding = port.getBinding();
+ PortType portType = binding.getPortType();
+
+ // find wrapper element for getMessageSDO return type
+ Operation op = portType.getOperation("getMessageSDO", null, null);
+ Output out = op.getOutput();
+ Message msg = out.getMessage();
+ Part part = msg.getPart(msg.getQName().getLocalPart());
+ QName elementQName = part.getElementName();
+
+ // find schema definition for wrapper element
+ Types types = definition.getTypes();
+ String elementNS = elementQName.getNamespaceURI();
+ Element schema = null;
+ for (Object ext : types.getExtensibilityElements()) {
+ ExtensibilityElement extElement = (ExtensibilityElement)ext;
+ if (SCHEMA_QNAME.equals(extElement.getElementType())) {
+ if (extElement instanceof Schema) {
+ Element schemaElement = ((Schema)extElement).getElement();
+ if (elementNS.equals(schemaElement.getAttribute("targetNamespace"))) {
+ schema = schemaElement;
+ break;
+ }
+ }
+ }
+ }
+
+ // find wrapper element definition in schema
+ String elementName = elementQName.getLocalPart();
+ Element wrapper = null;
+ NodeList childNodes = schema.getElementsByTagNameNS(SCHEMA_NS, "element");
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node childNode = childNodes.item(i);
+ if (childNode instanceof Element) {
+ String name = ((Element)childNode).getAttribute("name");
+ if (elementName.equals(name)) {
+ wrapper = (Element)childNode;
+ break;
+ }
+ }
+ }
+
+ // find xs:complexType child element
+ childNodes = wrapper.getElementsByTagNameNS(SCHEMA_NS, "complexType");
+ Element complexType = (Element)childNodes.item(0);
+
+ // find xs:sequence child element
+ childNodes = complexType.getElementsByTagNameNS(SCHEMA_NS, "sequence");
+ Element sequence = (Element)childNodes.item(0);
+
+ // find xs:element child element
+ childNodes = sequence.getElementsByTagNameNS(SCHEMA_NS, "element");
+ Element returnValue = (Element)childNodes.item(0);
+
+ // verify that return type is xs:anyType
+ assertEquals("xs:anyType", returnValue.getAttribute("type"));
+ }
+
+ /*
+ * Used for debugging DOM problems
+ */
+ private void printDOM(Node node){
+ try {
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ Source source = new DOMSource(node);
+ Result result = new StreamResult(System.out);
+ transformer.transform(source, result);
+ } catch (Exception ex){
+ ex.printStackTrace();
+ }
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ domain = SCADomain.newInstance("dynamic-sdo.composite");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+
+}
diff --git a/sca-java-1.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java b/sca-java-1.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java index 93c71cce6c..e3ec6dc6b7 100644 --- a/sca-java-1.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java +++ b/sca-java-1.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java @@ -30,6 +30,7 @@ import javax.xml.namespace.QName; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; import org.apache.tuscany.sca.databinding.XMLTypeHelper; +import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl; import org.apache.tuscany.sca.interfacedef.DataType; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.Operation; @@ -69,6 +70,8 @@ public class SDOTypeHelper implements XMLTypeHelper { QName xmlType = JavaXMLMapper.getXMLType(javaType); if (xmlType != null) { return new TypeInfo(xmlType, true, null); + } else if (javaType == commonj.sdo.DataObject.class) { + return new TypeInfo(SimpleTypeMapperImpl.XSD_ANYTYPE, true, null); } else { // introspect(javaType, xsdTypesMap, typesMap); if (logical instanceof XMLType) { |