summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-java-2.x/trunk/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorld.java2
-rw-r--r--sca-java-2.x/trunk/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorldImpl.java8
-rw-r--r--sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/client/HelloWorldClientLauncher.java40
-rw-r--r--sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService.wsdl28
-rw-r--r--sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService_schema1.xsd24
-rw-r--r--sca-java-2.x/trunk/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldService.java4
-rw-r--r--sca-java-2.x/trunk/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldServiceLauncher.java23
-rw-r--r--sca-java-2.x/trunk/itest/ws-jaxws/launcher-ri/src/test/java/org/apache/tuscany/sca/binding/ws/jaxws/launcher/JavaFirstTestCase.java52
8 files changed, 156 insertions, 25 deletions
diff --git a/sca-java-2.x/trunk/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorld.java b/sca-java-2.x/trunk/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorld.java
index 32f86ee30f..652f7b53c4 100644
--- a/sca-java-2.x/trunk/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorld.java
+++ b/sca-java-2.x/trunk/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorld.java
@@ -19,11 +19,13 @@
package org.apache.tuscany.sca.binding.ws.jaxws;
+import org.oasisopen.sca.ServiceRuntimeException;
import org.oasisopen.sca.annotation.Remotable;
@Remotable
public interface HelloWorld {
String getGreetings(String s);
+ String getGreetingsException(String s) throws ServiceRuntimeException;
Foo getGreetingsComplex(Foo foo);
}
diff --git a/sca-java-2.x/trunk/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorldImpl.java b/sca-java-2.x/trunk/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorldImpl.java
index e2c6ba4b65..85e55888c6 100644
--- a/sca-java-2.x/trunk/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorldImpl.java
+++ b/sca-java-2.x/trunk/itest/ws-jaxws/contribution-java-first/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/HelloWorldImpl.java
@@ -22,6 +22,7 @@ package org.apache.tuscany.sca.binding.ws.jaxws;
import javax.jws.WebService;
import org.apache.tuscany.sca.binding.ws.jaxws.external.service.jaxws.HelloWorldService;
+import org.oasisopen.sca.ServiceRuntimeException;
import org.oasisopen.sca.annotation.Reference;
@WebService
@@ -36,6 +37,13 @@ public class HelloWorldImpl implements HelloWorld {
System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
return response;
}
+
+ public String getGreetingsException(String s) throws ServiceRuntimeException {
+ System.out.println("Entering SCA HelloWorld.getGreetingsException: " + s);
+ String response = helloWorldExternal.getGreetings(s);
+ System.out.println("Leaving SCA HelloWorld.getGreetings: " + response);
+ throw new ServiceRuntimeException(response);
+ }
public Foo getGreetingsComplex(Foo foo){
Foo response = null;//helloWorldExternal.getGreetingsComplex(foo);
diff --git a/sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/client/HelloWorldClientLauncher.java b/sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/client/HelloWorldClientLauncher.java
index e8574d67e9..da40a7f442 100644
--- a/sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/client/HelloWorldClientLauncher.java
+++ b/sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/client/HelloWorldClientLauncher.java
@@ -25,23 +25,49 @@ import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
+import org.apache.tuscany.sca.binding.ws.jaxws.sca.Exception_Exception;
import org.apache.tuscany.sca.binding.ws.jaxws.sca.HelloWorldImpl;
public class HelloWorldClientLauncher {
- public static void main(String[] args) throws Exception {
+ public HelloWorldImpl wsProxy;
+
+ public HelloWorldClientLauncher(){
+ }
+
+ public void createClient() throws Exception{
System.out.println(">>> Starting external JAXWS client ");
-
+
// default JVM JAXWS support
QName serviceName = new QName("http://jaxws.ws.binding.sca.tuscany.apache.org/", "HelloWorldImplService");
QName portName = new QName("http://jaxws.ws.binding.sca.tuscany.apache.org/", "HelloWorldImplPort");
//URL wsdlLocation = new File("../external-client/target/classes/helloworld-sca.wsdl").toURL();
URL wsdlLocation = new File("../external-client/target/classes/HelloWorldImplService.wsdl").toURL();
javax.xml.ws.Service webService = Service.create(wsdlLocation, serviceName);
- HelloWorldImpl wsProxy = (HelloWorldImpl) webService.getPort(portName, HelloWorldImpl.class);
-
- String response = wsProxy.getGreetings("Fred");
-
- System.out.println("Leaving external JAXWS client: " + response);
+ wsProxy = (HelloWorldImpl) webService.getPort(portName, HelloWorldImpl.class);
+ }
+
+ public void destroyClient(){
+ System.out.println(">>> Stopping external JAXWS client: ");
+ // TODO
+ }
+
+ public String getGreetings(String name){
+ System.out.println("Entering External Client HelloWorld.getGreetings: " + name);
+ String response = wsProxy.getGreetings(name);
+ System.out.println("Leaving External Client HelloWorld.getGreetings: " + response);
+ return response;
+ }
+
+ public String getGreetingsException(String name) throws Exception_Exception {
+ return wsProxy.getGreetingsException(name);
+ }
+
+ public static void main(String[] args) throws Exception {
+ HelloWorldClientLauncher launcher = new HelloWorldClientLauncher();
+ launcher.createClient();
+ launcher.getGreetings("Fred");
+ launcher.destroyClient();
}
+
}
diff --git a/sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService.wsdl b/sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService.wsdl
index 8ae67d4270..0d9d17d1be 100644
--- a/sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService.wsdl
+++ b/sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService.wsdl
@@ -12,6 +12,15 @@
<message name="getGreetingsResponse">
<part name="parameters" element="tns:getGreetingsResponse"/>
</message>
+ <message name="getGreetingsException">
+ <part name="parameters" element="tns:getGreetingsException"/>
+ </message>
+ <message name="getGreetingsExceptionResponse">
+ <part name="parameters" element="tns:getGreetingsExceptionResponse"/>
+ </message>
+ <message name="Exception">
+ <part name="fault" element="tns:Exception"/>
+ </message>
<message name="getGreetingsComplex">
<part name="parameters" element="tns:getGreetingsComplex"/>
</message>
@@ -23,6 +32,11 @@
<input message="tns:getGreetings"/>
<output message="tns:getGreetingsResponse"/>
</operation>
+ <operation name="getGreetingsException">
+ <input message="tns:getGreetingsException"/>
+ <output message="tns:getGreetingsExceptionResponse"/>
+ <fault message="tns:Exception" name="Exception"/>
+ </operation>
<operation name="getGreetingsComplex">
<input message="tns:getGreetingsComplex"/>
<output message="tns:getGreetingsComplexResponse"/>
@@ -39,6 +53,18 @@
<soap:body use="literal"/>
</output>
</operation>
+ <operation name="getGreetingsException">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="Exception">
+ <soap:fault name="Exception" use="literal"/>
+ </fault>
+ </operation>
<operation name="getGreetingsComplex">
<soap:operation soapAction=""/>
<input>
@@ -56,3 +82,5 @@
</service>
</definitions>
+
+
diff --git a/sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService_schema1.xsd b/sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService_schema1.xsd
index 00d526db82..eef9ad4ead 100644
--- a/sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService_schema1.xsd
+++ b/sca-java-2.x/trunk/itest/ws-jaxws/external-client/src/main/resources/HelloWorldImplService_schema1.xsd
@@ -1,14 +1,38 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="http://jaxws.ws.binding.sca.tuscany.apache.org/" xmlns:tns="http://jaxws.ws.binding.sca.tuscany.apache.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="Exception" type="tns:Exception"/>
+
<xs:element name="getGreetings" type="tns:getGreetings"/>
<xs:element name="getGreetingsComplex" type="tns:getGreetingsComplex"/>
<xs:element name="getGreetingsComplexResponse" type="tns:getGreetingsComplexResponse"/>
+ <xs:element name="getGreetingsException" type="tns:getGreetingsException"/>
+
+ <xs:element name="getGreetingsExceptionResponse" type="tns:getGreetingsExceptionResponse"/>
+
<xs:element name="getGreetingsResponse" type="tns:getGreetingsResponse"/>
+ <xs:complexType name="getGreetingsException">
+ <xs:sequence>
+ <xs:element name="arg0" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="getGreetingsExceptionResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="Exception">
+ <xs:sequence>
+ <xs:element name="message" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+
<xs:complexType name="getGreetings">
<xs:sequence>
<xs:element name="arg0" type="xs:string" minOccurs="0"/>
diff --git a/sca-java-2.x/trunk/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldService.java b/sca-java-2.x/trunk/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldService.java
index 3dd039ff3c..796ef82792 100644
--- a/sca-java-2.x/trunk/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldService.java
+++ b/sca-java-2.x/trunk/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldService.java
@@ -35,9 +35,9 @@ public class HelloWorldService {
@ResponseWrapper(localName = "getGreetingsResponse", targetNamespace = "http://helloworld/external", className = "org.apache.tuscany.sca.binding.ws.jaxws.external.service.GetGreetingsResponse")
public String getGreetings( @WebParam(name = "name", targetNamespace = "http://helloworld/external")
String name) {
- System.out.println("Entering External HelloWorld.getGreetings: " + name);
+ System.out.println("Entering External Service HelloWorld.getGreetings: " + name);
String response = "Hello " + name;
- System.out.println("Leaving External HelloWorld.getGreetings: " + response);
+ System.out.println("Leaving External Service HelloWorld.getGreetings: " + response);
return response;
}
diff --git a/sca-java-2.x/trunk/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldServiceLauncher.java b/sca-java-2.x/trunk/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldServiceLauncher.java
index fc5fd6d701..ba7e033f63 100644
--- a/sca-java-2.x/trunk/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldServiceLauncher.java
+++ b/sca-java-2.x/trunk/itest/ws-jaxws/external-service/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/external/service/HelloWorldServiceLauncher.java
@@ -23,12 +23,27 @@ import javax.xml.ws.Endpoint;
public class HelloWorldServiceLauncher {
- public static void main(String[] args) throws Exception {
+ public Endpoint endpoint;
+
+ public HelloWorldServiceLauncher(){
+
+ }
+
+ public void createService(){
System.out.println(">>> Starting external JAXWS service at http://localhost:8086/External/HelloWorld");
// default JVM JAXWS support.
- Endpoint.publish("http://localhost:8086/External/HelloWorld",
- new HelloWorldService());
-
+ endpoint= Endpoint.publish("http://localhost:8086/External/HelloWorld",
+ new HelloWorldService());
+ }
+
+ public void destoryService(){
+ System.out.println(">>> Stopping external JAXWS service at http://localhost:8086/External/HelloWorld");
+ endpoint.stop();
}
+
+ public static void main(String[] args) throws Exception {
+ HelloWorldServiceLauncher launcher = new HelloWorldServiceLauncher();
+ launcher.createService();
+ }
}
diff --git a/sca-java-2.x/trunk/itest/ws-jaxws/launcher-ri/src/test/java/org/apache/tuscany/sca/binding/ws/jaxws/launcher/JavaFirstTestCase.java b/sca-java-2.x/trunk/itest/ws-jaxws/launcher-ri/src/test/java/org/apache/tuscany/sca/binding/ws/jaxws/launcher/JavaFirstTestCase.java
index 22ed3d17b4..3c14218118 100644
--- a/sca-java-2.x/trunk/itest/ws-jaxws/launcher-ri/src/test/java/org/apache/tuscany/sca/binding/ws/jaxws/launcher/JavaFirstTestCase.java
+++ b/sca-java-2.x/trunk/itest/ws-jaxws/launcher-ri/src/test/java/org/apache/tuscany/sca/binding/ws/jaxws/launcher/JavaFirstTestCase.java
@@ -19,26 +19,42 @@
package org.apache.tuscany.sca.binding.ws.jaxws.launcher;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import org.apache.tuscany.sca.binding.ws.jaxws.external.client.HelloWorldClientLauncher;
import org.apache.tuscany.sca.binding.ws.jaxws.external.service.HelloWorldServiceLauncher;
import org.apache.tuscany.sca.node.Contribution;
import org.apache.tuscany.sca.node.Node;
import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-public class JavaFirstTestCase extends TestCase {
+public class JavaFirstTestCase {
private Node node;
+ private HelloWorldServiceLauncher externalService;
+ private HelloWorldClientLauncher externalClient;
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
// Start the external service
- HelloWorldServiceLauncher.main(null);
+ externalService = new HelloWorldServiceLauncher();
+ externalService.createService();
// Start the SCA contribution
node = NodeFactory.newInstance().createNode(new Contribution("java-first", "../contribution-java-first/target/classes"));
node.start();
+
+ // start the external client
+ try {
+ externalClient = new HelloWorldClientLauncher();
+ externalClient.createClient();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
}
/*
@@ -46,16 +62,26 @@ public class JavaFirstTestCase extends TestCase {
System.out.println("Press a key");
System.in.read();
}
-*/
+*/
+
+ @Test
+ public void testGetGreetings() throws Exception {
+ assertEquals("Hello Fred", externalClient.getGreetings("Fred"));
+ }
- public void testCalculator() throws Exception {
+ @Test
+ public void testGetGreetingsException() throws Exception {
try {
- HelloWorldClientLauncher.main(null);
+ externalClient.getGreetingsException("Fred");
} catch (Exception ex) {
- ex.printStackTrace();
- throw ex;
+ return;
}
+ fail("expecting exception");
+ }
+
+ public void testGetGreetingsComplex() throws Exception {
+
/*
Foo f = new Foo();
Bar b1 = new Bar();
@@ -83,9 +109,11 @@ public class JavaFirstTestCase extends TestCase {
*/
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
node.stop();
+ externalClient.destroyClient();
+ externalService.destoryService();
}
}