Tuscany Calculator-Combo - A Simple SCA Assembly that hosts calculator functions as WebServices

Overview

This sample is an assembly of Calculator functions implemented in Java and exposed as Web Services. The primary objective of developing this sample is to support the Calculator-Combo sample.

To test this sample you might have to either run the Calculator-Combo sample after running this sample or you might right your won SCA Application that refereences the services of this sample

Location

The source for this sample is located  in the paths - samples\webapp\calculatorws of the source distribution.

If there is binary distribution available for these samples, then you may find these samples packaged as sample-calculatorws.war.

Building & Running the CalculatorWS Sample Source

If you are working with a source distribution, then you must first build the source of this sample.
- Ensure that you have Java 5 installed on your system.
- Next, you must have Maven 2.0.4 installed on your system. Look up http://maven.apache.org/download.html for downloading and installing Maven.
- Install the Apache Tomcat Server (latest release). Look up http://tomcat.apache.org/ for more information on releases and downloads.

Building the CalculatorWS Sample

Having installed Maven, open a command line console and switch over to the directory on your local system, where you have extracted the source.
- Now switch futher into the subdirectory samples\webapp\calculatorws. Within this directory execute the following command
> mvn
This will build the calculatorws sample, package a WAR file for the composite and make it available in the sub-directory samples\webapp\calculatorws\target

Running the CalculatorWS Sample

Now that the sample source has been built and Tomcat setup, you may run the Calculator WebService sample as follows: -

i) Copy the sample-calculatorws.war located in the samples\webapp\calculatorws\target into the WebApps directory of the Tomcat Installation.
ii) Ensure that the Calculator Web Application is up and running.


Trying the CalculatorWS Sample

To test this sample completely, run the Calculator-Combo sample after running this sample. For details on setting up and running the Calculator-Combo sample look at the readme.html under that sample.

Code Overview

The source files are physically organized as shown below:

Calculator WebService
+---main
+---java
| +---calculator <Interfaces and Implementations for Calculator Functions> +---resources +---wsdl calculator.wsdl +---webapp +---WEB-INF default.scdl web.xml

Calculator WebService Sample (WebApp Deployment)

default.scdl Defines an assembly of calculator funtions implemented in Java and exposed as a WebService using the Axis2 binding.
AddService.java
AddServiceImpl.java
DivideService.java
DivideServiceImpl.java
MathService.java
MathServiceImpl.java
MultiplyService.java
MultiplyServiceImpl.java
SubtractService.java
SubtractServiceImpl.java
Java Interfaces and Java Implementations for various calculator functions.
CalculatorService.java
CalculatorServiceImpl.java
Defines the coarse grained Calculator Interface and Implementation. This calculator implementation delegates function requests to other granular implemenations listed above.
calculator.wsdl Defines the Calculator service using WSDL to enable the CalculatorServiceImpl to be exposed as a Axis2 WebService
web.xml The Web App. descriptor for the Web App. deployment of the Tuscany Runtime.