Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This page walks you through the development of a complete sample application. It includes the following sections:

...

Sample Scenario

This sample is about the account opening process of a normal retail bank. We are going to develop a simple application to model that scenario using WSO2 Developer Studio. Here is a simplified description of a common retail banking process. When a potential customer walks into a bank branch to open an account, the first thing the bank does is establish the person's identity. Once the person's identity is established, the branch staff perform a query against a customer database to see if the person is an existing customer. Legacy banking systems are based on account numbers, but banks today are focused on getting a single view of the customer, which requires the generation of customer numbers. It's therefore important to ensure that a customer is not assigned more than one customer number by mistake. If the person is a prior customer, the customer number is retrieved from the customer database. If not, a fresh customer number is generated. This customer number is then associated with the new account number of the account that is to be opened. Accounts are still held on thirty year old mainframe systems, which alone can generate fresh account numbers. A debit card is normally issued with the first cheque or savings account that is opened. However, not all branches have the equipment to generate and issue them on the spot. Hence, cards are issued centrally and sent to the customers. If this is an existing customer, the new account is linked to their existing debit card on the spot. Most branches are unable to provide secure PIN printing facilities, so this too is centralised.

...

The following diagram shows how these components hang together.

New Server RuntimeImage Modified

Prerequisites

...

Following is the logical solution diagram that we are going to use while implementing the solution. This diagram shows how each and every WSO2 Product incorparate to come up with end to end solution.

New Server RuntimeImage Modified

In this sample, we are going to create seven projects for each and every component.

...

Open the Developer Studio Dashboard by clicking on clicking Open Dashboard option under  under top menu item Developer Studio.

New Server Runtime

To create a Data Service, click on click Data Service Project under the Data Services Server category.

Select Import Data Service and click Next.

New Server Runtime

Browse for the Data Services Descriptor file, CustomerDS.dbs under $DOWNLOAD_HOME/banking-sample/ds/dbs and click Finish.

New Server Runtime

Now you will see that the Data Service Project has been created in the workspace and make . Make sure to change the User Name and Password according to your MySQL credentials.

New Server Runtime

...

To create the Pojo Service, select click Axis2 Service Project from the Developer Studio Dashboard.

...

  • Project Name - MainframePojoService
  • Package Name - wso2.hcc
  • Class Name - MainframePojoService 

New Server RuntimeImage Removed
After giving the necessary details, click Finish. Now you can see that the Axis2 Service has been created in the workspace.

New Server Runtime

...

Now we want to enable JMS transport, since this service will communicate via JMS transport. To enable this, we need to add the following block to services.xml under /src/main/resources/META-INF.

  <
  transports
  >

   <
  transport
  >jms</
  transport
  >
</
  transports
  >

Now your services.xml will look like below.

New Server Runtime

Now we are done with modeling modelling the Account Service.

2. Modeling Card System

Now we want to create the Card System. This will be another Apache Axis2 Service Project. Select Click Axis2 Service Project from the WSO2 Developer Studio Dashboard as you done did in the previous step.

Select Create New Axis2 Service option from the wizard and give following details to Project Name, Package Name and Class Name.

  • Project Name - CardAxis2Service
  • Package Name - org.wso2.sample
  • Class Name - CardAxis2Service

...

  •  

Now you will see the CardAxis2Service has been created in the workspace. Now copy the original sources CardAxis2Service.java, Customer.java and Card.java from $DOWNLOAD_HOME/banking-sample/appserver/CardApplication/src/main/java/org/wso2/sample and paste in to org.wso2.sample package of the CardAxis2Service project. Now we are done with creating two mock services and we are ready to deploy those two services in to WSO2 Application Server.

...

3. Create a Composite Application Project to group mock objects

Open the Developer Studio Dashboard again and select click Composite Application Project.

Give a name to the Composite Application Project and select both services that we created.


 

Now you You will see that the Composite Application Project has been created in the workspace with the name you have specified.

...

4. Deploy the Composite Application Project in to WSO2 App Server

Now we are going to deploy the created Composite Application Project in to WSO2 Application Server. Before starting the WSO2 App Server, make sure Apache ActiveMQ is up and running.

...

Once you add the server successfully, start the server and add the BankingSample Composite Application to the running server.

New Server Runtime

...

As displayed in the console log, you can see that the MainframePojoService and CardAxis2Service have been deployed to WSO2 Application Server. Go to management console in the browser and check for Deployed Services.

Image Removed Image Added
 

If you click on the MainframePojoService and check for the  Endpoints section, you will see a JMS endpoint. This is because we have specified transport for this service as JMS.

  Image Removed Image Added

If you check on other service CardAxis2Service, you will see both HTTP and JMS transport endpoints are available.

Image RemovedImage Added

Now we are going to create proxy services to abstract the above two services.

...

1. Create an "address endpoint" for the mainframe on the ESB

Open the Developer Studio Dashboard and select Endpoint.

...

Now you will see that the endpoint has been created inside the ESB Project that you have created. Once you double click on the MainFrameEP node, you will see that the Properties view gets focused. You need to update the URI field with the correct JMS URI that appears in the App Server after deploying the two mock services.

Image RemovedImage Added 

Save the configuration and now we are done with the address endpoint.

...

Make sure the correct endpoint is being referenced. In the Properties window below, select the row with the Endpoint on it, then click on the button on the far right containing ellipsis (…).

Image RemovedImage Added

In the Resource Key Editor that pops up, select workspace.


 
Expand  Carbon Application Endpoints  and  ESB Configuration Project , then select  MainframeEP .

 

Save the proxy service and now we complete the proxy service that wrap the AccountService mock object.

...

Once the endpoint has been created, make sure that the correct URI has been specified.

Image RemovedImage Added

2. Create a service on the ESB that will act as a proxy to the Cards system

Right-click on the ESB Configuration Project and select New->Proxy Service. Select Create A New Proxy Service and click Next.
New Server RuntimeImage Removed

Give the name as CardService and select Custom Proxy from Proxy Service Type and click Finish.

New Server Runtime

...

In the Properties window below, select the row corresponding to WSDL Type, and change its value from NONE to SOURCE_URL and hit Enter. Now a new row will open up with the name Wsdl URL.

Image RemovedImage Added

In this field, we specify the actual file location of the WSDL file as file URI. The file CardService.wsdl can be found at $DOWNLOAD_HOME/banking-sample/appserver.Your file URI will be similar to: file:///$DOWNLOAD_HOME/banking-sample/appserver/CardService.wsdl .

Image RemovedImage Added

Drag and drop the XSLT mediator from the tool palette to the InSequence of the CardService proxy.

Image RemovedImage Added

Click on the newly created XSLT node, and change the Schema Key value to conf:/transform/transform.xslt.

 

This means that the transformation stylesheet is to be found in the local registry. But we don't have it there yet. The XSLT stylesheet used for transformation (transform.xslt) now needs to be imported into the local registry.

...

You can create before and after logging elements by dragging the Log mediator from the tool palette to before and after the XSLT.

Image RemovedImage Added

Drag and drop a Send mediator and then drag and drop the cardServiceEP that we created earlier from the defined endpoints.

Image RemovedImage Added

Now add a Send mediator as an OutSequence. We have successfully completed creating the proxy service for the card system.

Image RemovedImage Added

Create Registry Resource for transform.xslt

...

Select Import from file system option and  and click Next.

New Server Runtime

Select Browse file.. button and Click Browse and browse for the transform.xslt file at $DOWNLOAD_HOME/banking-sample/esb/cardService.

...

To create a BPEL Process, open the Developer Studio Dashboard and select click BPEL Workflow under the Business Process Server category.

Select Create New BPEL Workflow and click Next.
New Server RuntimeImage RemovedGive  

Enter AccountOpeningProcess as the Project Name and Process Name as AccountOpeningProcess and leave , and leave the default values for the other fields as default values. Then click Click Finish. New Server RuntimeImage Removed

Now you You will see that the new BPEL Workflow has been created in the workspace.

New Server Runtime

...

We will assume the mock services are already being deployed in to WSO2 App Server. Deploy the CAR file to WSO2 DSS, then to WSO2 ESB, and finally to WSO2 BPS. You can deploy Carbon Application from the management console of each server. Go to Manage -> Applications -> Add.

Image Removed Image Added  

Once you click this link, you will be prompted to select the CAR file you have saved to your file system. Upload it, then watch the console for messages that the CAR file has been deployed and the appropriate services have also been deployed.

New Server RuntimeImage Modified

You will find the following artifacts in different servers once you deploy the CAR file to all the servers. The application BankingSample should be listed in all the servers as well.

...

On the right hand side of the screen, under WSDL details, you will find a Create Instance link.

Image Removed Image Added
 

Click this link. A new tab will open up displaying two windows for the request and response messages. The request message has been formatted for you and you only have to enter values into the appropriate placeholders.

...

Enter a random integer value for nid and a string for name. Also enter the string CURRENT for accountType. Click Send. The response should be displayed in the other window with four fields including a card number.

Image RemovedImage Added

2. Test the account opening process with an existing customer

Click Send again without changing any of the values in the request. The response displayed in the other window now only has two fields. One of them is a new account number. Significantly, there should be no field for card number because existing customers already have debit cards.

Image RemovedImage Added