|
From: <fug...@us...> - 2007-11-02 02:05:49
|
Revision: 1817
http://cogkit.svn.sourceforge.net/cogkit/?rev=1817&view=rev
Author: fugangwang
Date: 2007-11-01 19:05:47 -0700 (Thu, 01 Nov 2007)
Log Message:
-----------
add a usable test example, which deployed a web service and invoke the service using a java client
Added Paths:
-----------
trunk/cyberaide/src/jaxws/testCircleService/
trunk/cyberaide/src/jaxws/testCircleService/CircleFunctions.java
trunk/cyberaide/src/jaxws/testCircleService/Makefile
trunk/cyberaide/src/jaxws/testCircleService/TestCircleFunctions.java
trunk/cyberaide/src/jaxws/testCircleService/stop.sh
Added: trunk/cyberaide/src/jaxws/testCircleService/CircleFunctions.java
===================================================================
--- trunk/cyberaide/src/jaxws/testCircleService/CircleFunctions.java (rev 0)
+++ trunk/cyberaide/src/jaxws/testCircleService/CircleFunctions.java 2007-11-02 02:05:47 UTC (rev 1817)
@@ -0,0 +1,46 @@
+/*
+ * CircleFunctions.java
+ *
+ * @version:
+ * $Id v1.0$
+ *
+ * @author:
+ * Fugang Wang
+ *
+ * Revisions:
+ * 10/28/2007 Initial version
+ * 11/01/2007 modify package name
+ *
+ */
+package testjaxws.service;
+
+import javax.jws.WebService;
+import javax.xml.ws.Endpoint;
+
+@WebService
+public class CircleFunctions {
+
+ /*
+ * return area of a circle
+ */
+ public double getArea(double r) {
+ return java.lang.Math.PI * (r * r);
+ }
+
+ /*
+ * return circumference of a circle
+ */
+ public double getCircumference(double r) {
+ return 2 * java.lang.Math.PI * r;
+ }
+
+ /*
+ * publish the service
+ */
+ public static void main(String[] args) {
+
+ Endpoint.publish(
+ "http://localhost:8080/jaxws/circlefunctions",
+ new CircleFunctions());
+ }
+}
Added: trunk/cyberaide/src/jaxws/testCircleService/Makefile
===================================================================
--- trunk/cyberaide/src/jaxws/testCircleService/Makefile (rev 0)
+++ trunk/cyberaide/src/jaxws/testCircleService/Makefile 2007-11-02 02:05:47 UTC (rev 1817)
@@ -0,0 +1,27 @@
+all: compile service client stop
+ @echo done
+
+init:
+ mkdir -p testjaxws
+
+compile: init
+ javac -d . CircleFunctions.java
+
+service:
+ @echo "Starting service..."
+ wsgen -cp . -r testjaxws -wsdl testjaxws.service.CircleFunctions
+ java testjaxws.service.CircleFunctions &
+ sleep 2
+
+client:
+ @echo "Generating and running client..."
+ wsimport -keep -p testjaxws.clientstub http://localhost:8080/jaxws/circlefunctions?WSDL
+ javac -d . TestCircleFunctions.java
+ java testjaxws.client.TestCircleFunctions
+
+stop:
+ @echo "Stopping service..."
+ sh stop.sh
+
+clean:
+ rm -fr testjaxws
Added: trunk/cyberaide/src/jaxws/testCircleService/TestCircleFunctions.java
===================================================================
--- trunk/cyberaide/src/jaxws/testCircleService/TestCircleFunctions.java (rev 0)
+++ trunk/cyberaide/src/jaxws/testCircleService/TestCircleFunctions.java 2007-11-02 02:05:47 UTC (rev 1817)
@@ -0,0 +1,68 @@
+/*
+ * TestCircleFunctions.java
+ *
+ * @version:
+ * $Id v1.0$
+ *
+ * @author:
+ * Fugang Wang
+ *
+ * Revisions:
+ * 10/28/2007 Initial version
+ * 11/01/2007 modify package name
+ *
+ */
+package testjaxws.client;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceRef;
+//import javax.jws.WebService;
+import testjaxws.clientstub.CircleFunctionsService;
+
+//@WebServiceRef(wsdlLocation = "http://localhost:8080/jaxws/circlefunctions?WSDL")
+
+public class TestCircleFunctions {
+ static CircleFunctionsService service = new CircleFunctionsService();
+
+ public static void main(String[] args) {
+ try {
+ TestCircleFunctions client = new TestCircleFunctions();
+ client.doTest(args);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void doTest(String[] args) {
+ try {
+ System.out.println("----------from Client running----------");
+ System.out.println("Retrieving the port from the following service:\n\t " + service);
+ testjaxws.clientstub.CircleFunctions port = service.getCircleFunctionsPort();
+ double radius,area,circumference;
+
+ System.out.println("Invoking the getCircumference operation on the port...");
+ System.out.print("Response from server:\n\tThe circumference of a circle with radius 5:");
+ radius = 5;
+ circumference = port.getCircumference(radius);
+ System.out.println( circumference );
+
+ System.out.println("Invoking the getArea operation on the port...");
+ System.out.print("Response from server:\n\tThe area of a circle with radius 10:");
+ radius = 10;
+ area = port.getArea(radius);
+ System.out.println( area );
+
+ System.out.println("Invoking the getCircumference operation on the port...");
+ System.out.print("Response from server:\n\tThe circumference of a circle with radius 10:");
+ circumference = port.getCircumference(radius);
+ System.out.println( circumference );
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Added: trunk/cyberaide/src/jaxws/testCircleService/stop.sh
===================================================================
--- trunk/cyberaide/src/jaxws/testCircleService/stop.sh (rev 0)
+++ trunk/cyberaide/src/jaxws/testCircleService/stop.sh 2007-11-02 02:05:47 UTC (rev 1817)
@@ -0,0 +1 @@
+kill -9 `ps -a|grep java|awk '{print $1}'`
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fug...@us...> - 2007-11-02 03:28:08
|
Revision: 1819
http://cogkit.svn.sourceforge.net/cogkit/?rev=1819&view=rev
Author: fugangwang
Date: 2007-11-01 20:28:05 -0700 (Thu, 01 Nov 2007)
Log Message:
-----------
add an test example which provides two different services on one host. A java client invokes the two services in one program.
Added Paths:
-----------
trunk/cyberaide/src/jaxws/testMultipleService/
trunk/cyberaide/src/jaxws/testMultipleService/CircleFunctions.java
trunk/cyberaide/src/jaxws/testMultipleService/Makefile
trunk/cyberaide/src/jaxws/testMultipleService/SquareFunctions.java
trunk/cyberaide/src/jaxws/testMultipleService/TestMultipleService.java
trunk/cyberaide/src/jaxws/testMultipleService/stop.sh
Added: trunk/cyberaide/src/jaxws/testMultipleService/CircleFunctions.java
===================================================================
--- trunk/cyberaide/src/jaxws/testMultipleService/CircleFunctions.java (rev 0)
+++ trunk/cyberaide/src/jaxws/testMultipleService/CircleFunctions.java 2007-11-02 03:28:05 UTC (rev 1819)
@@ -0,0 +1,46 @@
+/*
+ * CircleFunctions.java
+ *
+ * @version:
+ * $Id v1.0$
+ *
+ * @author:
+ * Fugang Wang
+ *
+ * Revisions:
+ * 10/28/2007 Initial version
+ * 11/01/2007 modify package name
+ * modify package name to use in multiple service deployment
+ */
+package testjaxws.service.circle;
+
+import javax.jws.WebService;
+import javax.xml.ws.Endpoint;
+
+@WebService
+public class CircleFunctions {
+
+ /*
+ * return area of a circle
+ */
+ public double getArea(double r) {
+ return java.lang.Math.PI * (r * r);
+ }
+
+ /*
+ * return circumference of a circle
+ */
+ public double getCircumference(double r) {
+ return 2 * java.lang.Math.PI * r;
+ }
+
+ /*
+ * publish the service
+ */
+ public static void main(String[] args) {
+
+ Endpoint.publish(
+ "http://localhost:8080/jaxws/circlefunctions",
+ new CircleFunctions());
+ }
+}
Added: trunk/cyberaide/src/jaxws/testMultipleService/Makefile
===================================================================
--- trunk/cyberaide/src/jaxws/testMultipleService/Makefile (rev 0)
+++ trunk/cyberaide/src/jaxws/testMultipleService/Makefile 2007-11-02 03:28:05 UTC (rev 1819)
@@ -0,0 +1,32 @@
+all: compile service client stop
+ @echo done
+
+init:
+ mkdir -p testjaxws
+
+compile: init
+ javac -d . CircleFunctions.java
+ javac -d . SquareFunctions.java
+
+service:
+ @echo "Starting the two services..."
+ wsgen -cp . -r testjaxws -wsdl testjaxws.service.circle.CircleFunctions
+ java testjaxws.service.circle.CircleFunctions &
+ sleep 2
+ wsgen -cp . -r testjaxws -wsdl testjaxws.service.square.SquareFunctions
+ java testjaxws.service.square.SquareFunctions &
+ sleep 2
+
+client:
+ @echo "Generating and running client..."
+ wsimport -keep -p testjaxws.clientstub.circle http://localhost:8080/jaxws/circlefunctions?WSDL
+ wsimport -keep -p testjaxws.clientstub.square http://localhost:8180/jaxws/squarefunctions?WSDL
+ javac -d . TestMultipleService.java
+ java testjaxws.client.TestMultipleService
+
+stop:
+ @echo "Stopping services..."
+ sh stop.sh
+
+clean:
+ rm -fr testjaxws
Added: trunk/cyberaide/src/jaxws/testMultipleService/SquareFunctions.java
===================================================================
--- trunk/cyberaide/src/jaxws/testMultipleService/SquareFunctions.java (rev 0)
+++ trunk/cyberaide/src/jaxws/testMultipleService/SquareFunctions.java 2007-11-02 03:28:05 UTC (rev 1819)
@@ -0,0 +1,45 @@
+/*
+ * SquareFunctions.java
+ *
+ * @version:
+ * $Id v1.0$
+ *
+ * @author:
+ * Fugang Wang
+ *
+ * Revisions:
+ * 11/01/2007 Initial version
+ *
+ */
+package testjaxws.service.square;
+
+import javax.jws.WebService;
+import javax.xml.ws.Endpoint;
+
+@WebService
+public class SquareFunctions {
+
+ /*
+ * return area of a Square
+ */
+ public double getArea(double s) {
+ return (s * s);
+ }
+
+ /*
+ * return circumference of a Square
+ */
+ public double getCircumference(double s) {
+ return 4 * s;
+ }
+
+ /*
+ * publish the service
+ */
+ public static void main(String[] args) {
+
+ Endpoint.publish(
+ "http://localhost:8180/jaxws/squarefunctions",
+ new SquareFunctions());
+ }
+}
Added: trunk/cyberaide/src/jaxws/testMultipleService/TestMultipleService.java
===================================================================
--- trunk/cyberaide/src/jaxws/testMultipleService/TestMultipleService.java (rev 0)
+++ trunk/cyberaide/src/jaxws/testMultipleService/TestMultipleService.java 2007-11-02 03:28:05 UTC (rev 1819)
@@ -0,0 +1,80 @@
+/*
+ * TestMultipleService.java
+ *
+ * @version:
+ * $Id v1.0$
+ *
+ * @author:
+ * Fugang Wang
+ *
+ * Revisions:
+ * 11/01/2007 Initial version
+ *
+ */
+package testjaxws.client;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceRef;
+//import javax.jws.WebService;
+import testjaxws.clientstub.circle.CircleFunctionsService;
+import testjaxws.clientstub.square.SquareFunctionsService;
+
+//@WebServiceRef(wsdlLocation = "http://localhost:8080/jaxws/circlefunctions?WSDL")
+
+public class TestMultipleService {
+ static CircleFunctionsService service1 = new CircleFunctionsService();
+ static SquareFunctionsService service2 = new SquareFunctionsService();
+
+ public static void main(String[] args) {
+ try {
+ TestMultipleService client = new TestMultipleService();
+ client.doTest(args);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void doTest(String[] args) {
+ try {
+ System.out.println("------------------from Client running------------------");
+ System.out.println("----------try to call the first service----------");
+ System.out.println("Retrieving the port from the following service:\n\t " + service1);
+ testjaxws.clientstub.circle.CircleFunctions port1 = service1.getCircleFunctionsPort();
+ double radius,area,circumference;
+
+ System.out.println("Invoking the getArea operation on the port...");
+ System.out.print("Response from server:\n\tThe area of a circle with radius 10:");
+ radius = 10;
+ area = port1.getArea(radius);
+ System.out.println( area );
+
+ System.out.println("Invoking the getCircumference operation on the port...");
+ System.out.print("Response from server:\n\tThe circumference of a circle with radius 10:");
+ circumference = port1.getCircumference(radius);
+ System.out.println( circumference );
+
+ System.out.println("----------try to get to another service----------");
+ System.out.println("Retrieving the port from the following service:\n\t " + service2);
+ testjaxws.clientstub.square.SquareFunctions port2 = service2.getSquareFunctionsPort();
+ double side = 10;
+
+ System.out.println("Invoking the getArea operation on the port...");
+ System.out.print("Response from server:\n\tThe area of a square with side 10:");
+ area = port2.getArea(radius);
+ System.out.println( area );
+
+ System.out.println("Invoking the getCircumference operation on the port...");
+ System.out.print("Response from server:\n\tThe circumference of a square with side 10:");
+ circumference = port2.getCircumference(radius);
+ System.out.println( circumference );
+
+
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Added: trunk/cyberaide/src/jaxws/testMultipleService/stop.sh
===================================================================
--- trunk/cyberaide/src/jaxws/testMultipleService/stop.sh (rev 0)
+++ trunk/cyberaide/src/jaxws/testMultipleService/stop.sh 2007-11-02 03:28:05 UTC (rev 1819)
@@ -0,0 +1 @@
+kill -9 `ps -a|grep java|awk '{print $1}'`
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fug...@us...> - 2007-11-02 16:58:52
|
Revision: 1820
http://cogkit.svn.sourceforge.net/cogkit/?rev=1820&view=rev
Author: fugangwang
Date: 2007-11-02 09:58:51 -0700 (Fri, 02 Nov 2007)
Log Message:
-----------
change directory structure, package name, and Makefile so that the generated files are stored into a separate build directory
Added Paths:
-----------
trunk/cyberaide/src/jaxws/test/
trunk/cyberaide/src/jaxws/test/README.txt
Removed Paths:
-------------
trunk/cyberaide/src/jaxws/testCircleService/
trunk/cyberaide/src/jaxws/testMultipleService/
Added: trunk/cyberaide/src/jaxws/test/README.txt
===================================================================
--- trunk/cyberaide/src/jaxws/test/README.txt (rev 0)
+++ trunk/cyberaide/src/jaxws/test/README.txt 2007-11-02 16:58:51 UTC (rev 1820)
@@ -0,0 +1,3 @@
+./testCircleService/ contains a test example to deploy a web service using jaxws and consume it from a java client program
+./testMultipleService/ contains a test example to deploy two web services at one host using jaxws and consume the two services from a single java client program
+The build class files and stubs generated by wsgen and wsimport are stored in /cyberaide/build/org/cogkit/cyberaide/jaxws/test; the generated wsdl files are stored in /cyberaide/build/wsdl
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fug...@us...> - 2007-11-02 17:58:51
|
Revision: 1823
http://cogkit.svn.sourceforge.net/cogkit/?rev=1823&view=rev
Author: fugangwang
Date: 2007-11-02 10:58:50 -0700 (Fri, 02 Nov 2007)
Log Message:
-----------
put the example files to the newly arranged directory structure
Removed Paths:
-------------
trunk/cyberaide/src/jaxws/Makefile
trunk/cyberaide/src/jaxws/README.txt
Deleted: trunk/cyberaide/src/jaxws/Makefile
===================================================================
--- trunk/cyberaide/src/jaxws/Makefile 2007-11-02 17:52:09 UTC (rev 1822)
+++ trunk/cyberaide/src/jaxws/Makefile 2007-11-02 17:58:50 UTC (rev 1823)
@@ -1,43 +0,0 @@
-help:
-
- @echo
- @echo "Ussage"
- @echo
- @echo " make compile - compiles all the source code"
- @echo " make service - generates the web service"
- @echo " make start - starts the Web Service"
- @echo " make wsdl - display in mozilla the wsdl file"
- @echo
- @echo "NOT YET IMPLEMENTED:"
- @echo " make stop - stops the Web Service"
- @echo " make stopall - stops all java processes"
- @echo " make run - runs a client process"
-
-all: compile service run
- echo done
-
-compile:
-# cd hello; javac CircleFunctionsClient.java
- cd hello; javac CircleFunctions.java
-
-service:
- wsgen -cp . hello.CircleFunctions
-
-start:
- java hello.CircleFunctions
-
-wsdl:
- mozilla http://localhost:8080/jaxws/circlefunctions?WSDL
-stop:
-
-stopall:
- #write shell script that stops all java processes
-
-run:
-
-ls:
- echo lists all java processes
- ps -aux | fgrep java
-
-clean:
- rm -f *.class */*.class */*/*.class
Deleted: trunk/cyberaide/src/jaxws/README.txt
===================================================================
--- trunk/cyberaide/src/jaxws/README.txt 2007-11-02 17:52:09 UTC (rev 1822)
+++ trunk/cyberaide/src/jaxws/README.txt 2007-11-02 17:58:50 UTC (rev 1823)
@@ -1 +0,0 @@
-see ../../README.txt
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|