Mortgage Sample

Overview

The Tuscany Web services client Helloworld sample shows how to call a remote Web service by wiring an SCA component to a reference which uses a Web service binding.

Prerequisites

Obtain the following prerequisites and install according to their documentation.

The business scenario

The "loan approval" application accepts a mortgage request including the customer's details and the requested loan amount. It first checks the credit of the customer to make sure the credit score meets the minimum requirement. The interest rate is determined based on the principal requested, the term for the loan and the customers home state. It then uses a mortgage calculator to calculate the ratio by dividing potential monthly payment by the customer's income. The ratio and credit score are passed to perform the risk assessment which makes the final decision.

Packaging structure

Building

To build the sample  issue :

mvn

The result after executing is in the target subdirectory the sample-mortgage.jar

Setup

Set up the Tuscany standalone runtime environment using the following command:

mvn dependency:unpack 

After completion there should be a target\distribution subdirectory created that has the Tuscany standalone runtime.

The Tuscany Web servivces binding requires the Axis2 and SDO databinding extensions so copy these to the standalone launcher extensions directory:

copy target\distribution\contrib\axis2-1.0-incubator-M2.jar target\distribution\extensions
copy target\distribution\contrib\databinding-sdo-1.0-incubator-M2.jar target\distribution\extensions

Running

Execute the following command: (cut and paste to command line)

java -jar target/distribution/bin/launcher.jar target/sample-mortgage.jar

Results

The sample when run should simply display to the standard output:

Approved: John Smith[111-22-3333]

We have two versions of the CreditCheck web service implementation in this sample application:

Deploy the Axis2 CreditCheck web service to Tomcat

  1. Download the WAR (Web Archive) ditribution from Apache Axis2 1.1 release download site.
  2. Copy axis2.war to <tomcat_home>\webapps.
  3. Start Tomcat so that axis2.war get deployed to <tomcat_home>\webapps\axis2.
  4. Copy creditws-axis2\build\lib\CreditCheckService.aar to <tomcat_home>\webapps\axis2\WEB-INF\services.

Deploy the CreditComposite to Tomcat

  1. Copy credit.war to <tomcat_home>\webapps.
  2. Start Tomcat so that credit.war get deployed to <tomcat_home>\webapps\credit. The CreditCheck web serivice will be up and running.