tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r577075 - in /incubator/tuscany/branches/sca-java-1.0: itest/ itest/ws-void-args-return/ itest/ws-void-args-return/src/ itest/ws-void-args-return/src/main/ itest/ws-void-args-return/src/main/java/ itest/ws-void-args-return/src/main/java/voi...
Date Tue, 18 Sep 2007 21:44:03 GMT
Author: rfeng
Date: Tue Sep 18 14:44:01 2007
New Revision: 577075

URL: http://svn.apache.org/viewvc?rev=577075&view=rev
Log:
Apply the patch from Simon Nash for TUSCANY-1658

Added:
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/   (with props)
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/pom.xml   (with props)
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldImpl.java
  (with props)
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldService.java
  (with props)
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClient.java
  (with props)
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClientImpl.java
  (with props)
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/resources/
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/resources/voidtest.composite
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/test/
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/test/java/
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/test/java/voidtest/
    incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/test/java/voidtest/VoidArgsReturnTestCase.java
  (with props)
    incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/ExampleService.java
  (with props)
Modified:
    incubator/tuscany/branches/sca-java-1.0/itest/pom.xml
    incubator/tuscany/branches/sca-java-1.0/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
    incubator/tuscany/branches/sca-java-1.0/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Java2WSDLHelper.java
    incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2OMBuilder.java
    incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLTestCase.java

Modified: incubator/tuscany/branches/sca-java-1.0/itest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/itest/pom.xml?rev=577075&r1=577074&r2=577075&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/itest/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-1.0/itest/pom.xml Tue Sep 18 14:44:01 2007
@@ -72,6 +72,7 @@
                 <module>wsdl</module>
                 <module>wsdlless</module>
                 <module>wsdl2java</module>
+                <module>ws-void-args-return</module>
             </modules>
         </profile>
 

Propchange: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Sep 18 14:44:01 2007
@@ -0,0 +1,14 @@
+target
+*.iws
+*.ipr
+*.iml
+.project
+.classpath
+maven.log
+velocity.log*
+junit*.properties
+surefire*.properties
+.settings
+.deployables
+.wtpmodules
+

Added: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/pom.xml?rev=577075&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/pom.xml (added)
+++ incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/pom.xml Tue Sep 18 14:44:01
2007
@@ -0,0 +1,61 @@
+<?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-itest</artifactId>
+        <version>1.0-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>itest-ws-void-args-return</artifactId>
+    <name>Apache Tuscany SCA Web Services Void Args and Return Test</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-embedded</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-binding-ws-axis2</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-tomcat</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+    </dependencies>
+    
+</project>

Propchange: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldImpl.java?rev=577075&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldImpl.java
(added)
+++ incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldImpl.java
Tue Sep 18 14:44:01 2007
@@ -0,0 +1,49 @@
+/*
+ * 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 voidtest;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+
+    public String getGreetings(String name) {
+        return "Hello " + name;
+    }
+
+    public void giveGreetings(String name) {
+        System.out.println("Hello " + name);
+    }
+
+    public void giveGreetingsOneWay(String name) {
+        System.out.println("Hi " + name);
+    }
+
+    public String takeGreetings() {
+        return "Hello Stranger";
+    }
+
+    public void noGreetings() {
+        System.out.println("Hello, who's there?");
+    }
+
+}

Propchange: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldService.java?rev=577075&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldService.java
(added)
+++ incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldService.java
Tue Sep 18 14:44:01 2007
@@ -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 voidtest;
+
+import org.osoa.sca.annotations.OneWay;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface HelloWorldService {
+
+    String getGreetings(String name);
+
+    void giveGreetings(String name);
+
+    @OneWay
+    void giveGreetingsOneWay(String name);
+
+    String takeGreetings();
+
+    void noGreetings();
+}
+

Propchange: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/HelloWorldService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClient.java?rev=577075&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClient.java
(added)
+++ incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClient.java
Tue Sep 18 14:44:01 2007
@@ -0,0 +1,23 @@
+/*
+ * 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 voidtest;
+
+public interface TestClient {
+    void runTest();
+}

Propchange: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClient.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClientImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClientImpl.java?rev=577075&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClientImpl.java
(added)
+++ incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClientImpl.java
Tue Sep 18 14:44:01 2007
@@ -0,0 +1,45 @@
+/*
+ * 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 voidtest;
+
+import static junit.framework.Assert.assertEquals;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(TestClient.class)
+@Scope("COMPOSITE")
+public class TestClientImpl implements TestClient {
+
+    private HelloWorldService helloService;
+
+    @Reference
+    public void setHelloService(HelloWorldService helloService) {
+        this.helloService = helloService;
+    }
+
+    public void runTest() {
+        assertEquals("Hello Smith", helloService.getGreetings(" Smith"));
+        helloService.giveGreetings("Jones");
+        helloService.giveGreetingsOneWay("Brown");
+        assertEquals("Hello Stranger", helloService.takeGreetings());
+        helloService.noGreetings();
+    }
+}

Propchange: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClientImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/java/voidtest/TestClientImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/resources/voidtest.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/resources/voidtest.composite?rev=577075&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/resources/voidtest.composite
(added)
+++ incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/main/resources/voidtest.composite
Tue Sep 18 14:44:01 2007
@@ -0,0 +1,41 @@
+<?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://voidtest"
+    xmlns:hw="http://voidtest"
+    name="voidtest">
+
+    <component name="TestClientComponent">
+        <implementation.java class="voidtest.TestClientImpl" />
+        <reference name="helloService">
+            <interface.java interface="voidtest.HelloWorldService"/>
+            <binding.ws uri="http://localhost:8085/HelloWorldServiceComponent/HelloWorldService"/>
+        </reference>
+    </component>
+
+    <component name="HelloWorldServiceComponent">
+        <implementation.java class="voidtest.HelloWorldImpl" />
+        <service name="HelloWorldService">
+            <interface.java interface="voidtest.HelloWorldService"/>
+            <binding.ws uri="http://localhost:8085/HelloWorldServiceComponent/HelloWorldService"/>
+        </service>
+    </component>
+
+</composite>

Added: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/test/java/voidtest/VoidArgsReturnTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/test/java/voidtest/VoidArgsReturnTestCase.java?rev=577075&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/test/java/voidtest/VoidArgsReturnTestCase.java
(added)
+++ incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/test/java/voidtest/VoidArgsReturnTestCase.java
Tue Sep 18 14:44:01 2007
@@ -0,0 +1,53 @@
+/*
+ * 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 voidtest;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests that methods with no args and/or void return type work over Web services
+ */
+public class VoidArgsReturnTestCase {
+
+    private SCADomain scaDomain;
+    private TestClient client;
+
+    @Before
+    public void startServer() throws Exception {
+        scaDomain = SCADomain.newInstance("voidtest.composite");
+        client = scaDomain.getService(TestClient.class, "TestClientComponent");
+    }
+
+    @Test
+    public void testVoidCases() throws Exception {
+        client.runTest();
+        System.out.println("Sleeping...");
+        Thread.sleep(2000);
+    }
+
+    @After
+    public void stopServer() throws Exception {
+        scaDomain.close();
+    }
+
+}

Propchange: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/test/java/voidtest/VoidArgsReturnTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/branches/sca-java-1.0/itest/ws-void-args-return/src/test/java/voidtest/VoidArgsReturnTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/branches/sca-java-1.0/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java?rev=577075&r1=577074&r2=577075&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
(original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
Tue Sep 18 14:44:01 2007
@@ -108,7 +108,9 @@
         // FIXME: [rfeng] We have to pay performance penality to build the complete OM as
the operationClient.complete() will
         // release the underlying HTTP connection. 
         // Force the response to be populated, see https://issues.apache.org/jira/browse/TUSCANY-1541
-        response.build();
+        if (response != null) {
+            response.build();
+        }
 
         operationClient.complete(requestMC);
 

Modified: incubator/tuscany/branches/sca-java-1.0/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Java2WSDLHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Java2WSDLHelper.java?rev=577075&r1=577074&r2=577075&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Java2WSDLHelper.java
(original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Java2WSDLHelper.java
Tue Sep 18 14:44:01 2007
@@ -22,17 +22,29 @@
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Method;
 import java.net.URL;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
 import javax.wsdl.Definition;
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.OperationType;
+import javax.wsdl.Output;
+import javax.wsdl.Part;
 import javax.wsdl.Port;
 import javax.wsdl.PortType;
 import javax.wsdl.Service;
 import javax.wsdl.Types;
 import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLLocator;
 import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
@@ -53,6 +65,8 @@
 import org.apache.tuscany.sca.policy.IntentAttachPoint;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.java2wsdl.Java2WSDLBuilder;
+import org.osoa.sca.annotations.OneWay;
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.InputSource;
 
@@ -88,8 +102,18 @@
 
         try {
             for (Operation op : iface.getOperations()) {
+                javax.wsdl.Operation wsdlOp = portType.getOperation(op.getName(), null, null);
+                WSDLOperationIntrospectorImpl opx =
+                    new WSDLOperationIntrospectorImpl(wsdlFactory, wsdlOp, wsdlDefinition.getInlinedSchemas(),
null,
+                                                      null);
+
                 Operation clonedOp = (Operation)op.clone();
                 clonedOp.setDataBinding(null);
+
+                if (clonedOp.getInputType().getLogical().isEmpty()) {
+                    // null args case needs a single input type for the wrapper
+                    clonedOp.setInputType(opx.getInputType());
+                }
                 for (DataType<?> dt : clonedOp.getInputType().getLogical()) {
                     dt.setDataBinding(null);
                 }
@@ -101,10 +125,6 @@
                     dt.setDataBinding(null);
                 }
                 clonedOp.setWrapperStyle(true);
-                javax.wsdl.Operation wsdlOp = portType.getOperation(op.getName(), null, null);
-                WSDLOperationIntrospectorImpl opx =
-                    new WSDLOperationIntrospectorImpl(wsdlFactory, wsdlOp, wsdlDefinition.getInlinedSchemas(),
null,
-                                                      null);
                 clonedOp.setWrapper(opx.getWrapper().getWrapperInfo());
 
                 wsdlInterface.getOperations().add(clonedOp);
@@ -167,6 +187,7 @@
             Definition definition = reader.readWSDL(locator);
             
             processSOAPVersion(definition, wsBinding);
+            processNoArgAndVoidReturnMethods(definition, javaInterface);
 
             return definition;
 
@@ -177,9 +198,9 @@
 
     private static void processSOAPVersion(Definition definition, WebServiceBinding wsBinding)
{
         if (requiresSOAP12(wsBinding)) {
-            removePort(definition, "SOAP11port");
+             removePort(definition, "SOAP11port_http");
          } else {
-             removePort(definition, "SOAP12port");
+             removePort(definition, "SOAP12port_http");
          }
     }
 
@@ -208,6 +229,119 @@
         }
         return false;
     }
+
+    private static void processNoArgAndVoidReturnMethods(Definition definition, Class javaInterface)
{
+        String namespaceURI = definition.getTargetNamespace();
+        String prefix = definition.getPrefix(namespaceURI);
+        String xsPrefix = definition.getPrefix("http://www.w3.org/2001/XMLSchema");
+        PortType portType = (PortType)definition.getAllPortTypes().values().iterator().next();
+
+        Element schema = null;
+        Document document = null;
+        Types types = definition.getTypes();
+        if (types != null) {
+            for (Object ext : types.getExtensibilityElements()) {
+                if (ext instanceof Schema) {
+                    Element element = ((Schema)ext).getElement();
+                    if (element.getAttribute("targetNamespace").equals(namespaceURI)) {
+                        schema = element;
+                        document = schema.getOwnerDocument();
+                        break;
+                    }
+                }
+            }
+        }
+        if (document == null) {
+            return;
+        }
+
+        // look at each operation in the port type to see if it needs fixing up
+        for (Object oper : portType.getOperations()) {
+            javax.wsdl.Operation operation = (javax.wsdl.Operation)oper;
+            String opName = operation.getName();
+
+            // if input message has no parts, add one containing an empty wrapper
+            Input input = operation.getInput();
+            if (input != null) {
+                Message inputMsg = input.getMessage();
+                if (inputMsg.getParts().isEmpty()) {
+                    // create wrapper element and add it to the schema DOM
+                    Element wrapper = document.createElementNS("http://www.w3.org/2001/XMLSchema",
+                                                               xsPrefix + ":element");
+                    wrapper.setAttribute("name", opName);
+                    schema.appendChild(wrapper);
+                    Element complexType = document.createElementNS("http://www.w3.org/2001/XMLSchema",
+                                                                   xsPrefix + ":complexType");
+                    wrapper.appendChild(complexType);
+
+                    // create new part for the wrapper and add it to the message
+                    Part part = definition.createPart();
+                    part.setName("parameters");
+                    part.setElementName(new QName(namespaceURI, opName, prefix));
+                    inputMsg.addPart(part);
+                }
+            }
+
+            // if two-way operation has no output message, add one containing an empty wrapper
+            if (input != null && operation.getOutput() == null) {
+                boolean isOneWay = false;
+                Method[] methods = javaInterface.getMethods();
+                for (Method method : methods) {
+                    if (method.getName().equals(opName) && method.getAnnotation(OneWay.class)
!= null) {
+                        isOneWay = true;
+                    }
+                }
+                if (!isOneWay) {
+                    // create wrapper element and add it to the schema DOM
+                    String msgName = opName + "Response";
+                    Element wrapper = document.createElementNS("http://www.w3.org/2001/XMLSchema",
+                                                               xsPrefix + ":element");
+                    wrapper.setAttribute("name", msgName);
+                    schema.appendChild(wrapper);
+                    Element complexType = document.createElementNS("http://www.w3.org/2001/XMLSchema",
+                                                                   xsPrefix + ":complexType");
+                    wrapper.appendChild(complexType);
+
+                    // create new part for the wrapper
+                    Part part = definition.createPart();
+                    part.setName("parameters");
+                    part.setElementName(new QName(namespaceURI, msgName, prefix));
+
+                    // create new message for the part
+                    Message outputMsg = definition.createMessage();
+                    outputMsg.setQName(new QName(namespaceURI, msgName, prefix));
+                    outputMsg.addPart(part);
+                    outputMsg.setUndefined(false);
+                    definition.addMessage(outputMsg);
+
+                    // create output element for the operation
+                    Output output = definition.createOutput();
+                    output.setMessage(outputMsg);
+                    output.setExtensionAttribute(new QName("http://www.w3.org/2006/05/addressing/wsdl",
"Action"),
+                                                 new QName("urn:" + msgName));
+                    operation.setOutput(output);
+                    operation.setStyle(OperationType.REQUEST_RESPONSE);
+
+                    // add binding output element to bindings for this port type
+                    for (Object bindObj : definition.getAllBindings().values()) {
+                        Binding binding = (Binding)bindObj;
+                        if (binding.getPortType().equals(portType)) {
+                            BindingOperation op = binding.getBindingOperation(opName, null,
null);
+                            if (op != null && op.getBindingInput() != null &&
op.getBindingOutput() == null) {
+                                BindingOutput bindingOut = definition.createBindingOutput();
+                                for (Object extObj : op.getBindingInput().getExtensibilityElements())
{
+                                    bindingOut.addExtensibilityElement((ExtensibilityElement)extObj);
+                                }
+                                op.setBindingOutput(bindingOut);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+    }
+
 }
 
 class WSDLLocatorImpl implements WSDLLocator {

Modified: incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2OMBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2OMBuilder.java?rev=577075&r1=577074&r2=577075&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2OMBuilder.java
(original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2OMBuilder.java
Tue Sep 18 14:44:01 2007
@@ -232,7 +232,8 @@
                     + MESSAGE_SUFFIX, null);
                 operation.addChild(message);
 
-                if (!jmethod.getReturnType().isVoidType()) {
+                if (!jmethod.getReturnType().isVoidType() ||
+                    jmethod.getAnnotation("org.osoa.sca.annotations.OneWay") == null) {
                     message = fac.createOMElement(OUT_PUT_LOCAL_NAME, wsdl);
                     message.addAttribute(MESSAGE_LOCAL_NAME, tns.getPrefix() + COLON_SEPARATOR
                         + jmethod.getSimpleName()

Added: incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/ExampleService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/ExampleService.java?rev=577075&view=auto
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/ExampleService.java
(added)
+++ incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/ExampleService.java
Tue Sep 18 14:44:01 2007
@@ -0,0 +1,31 @@
+/*
+ * 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 org.apache.tuscany.tools.java2wsdl.generate;
+
+import org.osoa.sca.annotations.OneWay;
+
+public interface ExampleService {
+
+    void sayHelloTwoWay(String name);
+
+    @OneWay
+    void sayHelloOneWay(String name);
+    
+    String getGreeting();
+}

Propchange: incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/ExampleService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/ExampleService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLTestCase.java?rev=577075&r1=577074&r2=577075&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLTestCase.java
(original)
+++ incubator/tuscany/branches/sca-java-1.0/modules/java2wsdl/src/test/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyJava2WSDLTestCase.java
Tue Sep 18 14:44:01 2007
@@ -87,6 +87,20 @@
     }
 
     /**
+     * Test WSDL generation for a service interface.
+     */
+    public void testServiceWSDLGeneration() {
+        String[] arguments =
+            new String[] {"-cn", "org.apache.tuscany.tools.java2wsdl.generate.ExampleService",

+                          "-o",  "target/java2wsdl-source"};
+
+        Java2WSDL.main(arguments);
+
+        File file = new File("target/java2wsdl-source/ExampleService.wsdl");
+        assertTrue(file.exists() && file.isFile());
+    }
+
+    /**
      * Test WSDL generation from a java interface and then generate the java
      * interface using the generated WSDL.
      */



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message