
Skip to end of metadata
Go to start of metadata

You can find all files for this example in

Service chaining is a popular use case in WSO2 ESB. In lot of usecases business functionalities defined in different services are exposed as a single service to the outside world.

Scenario Description

This is an integration scenario that can be implemented using an ESB. The WSO2 ESB allows for easy-to-manage central control for exposing the services as a single service and usually the configuration of the ESB can be changed depending on the service requirement changes.

Objective: To expose a virtual service that requires two other real web services to fulfill a single request. For a single request, the two web services will be called in order because they have data dependencies between them.

The following scheme visually displays the processes running in this example.

ESB receives a credit request from a proxy service called CreditProxy (Step 1). The request has the ID of the requestor of the operation and the credit amount. But to call the CreditService deployed in the WSO2 Application Server the request must also be enriched with the name and address information of the requestor. This information can be obtained from the PersonInfoService deployed in the WSO2 Application Server (Step 2). So firstly we need to call the PersonInfoService and enrich the request with the name and address (Step 3) before calling the CreditService (Step 4).

In this example, we have two back-end services and one proxy service. WSDLs for the examples can be found in the

  • CreditProxy - This service is in the WSO2 ESB and it is exposed to customers. This service accepts an ID and a credit amount for its credit operation. A request coming to this service is served by two back-end services.
  • PersonInfoService -The PersonInfoService provides the name and address information about a requestor when the ID is given. So, this is the first service being called by the CreditProxy service deployed in the ESB.
  • CreditService - The CreditService is the actual service that does the crediting. It is called by the CreditProxy (Step 5) after getting the required information from the PersonInfoService.

Scenario Set-up

The scenario needs installation and configuration of the following applications:

  • WSO2 ESB
  • WSO2 Application Server


The article deals with the ESB 3.0.1. Do not forget to change configurations according to your version.

Follow the instructions bellow to configure these servers.

Step 1. Set up the Back-end Services

Deploy the esb-samples-1.0-SNAPSHOT.jar as a JAR service in to the WSO2 Application Server.

1. In the Application Server web interface, click "Add" under "Services" in the left menu. Then select the "Jar Service" menu item.

2. Then in the "Add Jar Service" page, define the Service Group name. Click "Browse" to add the JAR file.

3. Select the file from the attached archive.

4. Click "Next" in the "Add Jar Service" page.

5. This JAR has two POJO services. The required classes that need to be exposed as web services are:

  • org.wso2.esb.samples.CreditService
  • org.wso2.esb.samples.PersonInfoService

Select the "org.wso2.esb.samples.CreditService" and "org.wso2.esb.samples.PersonInfoService" checkboxes. Click "Next."

6. Make sure the "credit" and "get" methods are selected. Click "Finish."

7. The success message is displayed.

The added service group is displayed on the "Deployed Services" window.

Step 2. Configure ESB
  1. Copy the synapse-config folder from the to repository/conf of WSO2 ESB and replace the synapse-config folder.
  2. Copy personToCredit.xslt from the to the resources directory of WSO2 ESB.
  3. Copy CreditProxy.wsdl from the to the resources directory of the WSO2 ESB.


If you are running WSO2 ESB on the same machine as WSO2 Application Server, be sure to set the port offset accordingly.

Running the Scenario

1. Once configured, the following applications should be run: 

  • WSO2 ESB
  • WSO2 Application Server

2. You can use the soapUI tool to control the results of running the scenario.

Create a new project in soapUI.

3. Select CreditProxy.wsdl to use as initial WSDL for this project.

4. Then call this proxy service using the soapUI.

The following screen-shot highlights the entered values and the value returned as the result of service work. The response time is also marked.


This scenario does not have any error handling. To implement the error handling, an error handling sequence must be added to the proxy service.

  • No labels