This documentation is for WSO2 Business Rules Server 2.1.0.View documentation for the latest release.

Versions Compared


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


Deploying and testing the service

  1. Deploy the rule service through the BRS management console. You can follow either of the two methods:

    • Bundle all artifacts in an .aar file and upload it (Rule Service -> Upload menu).
    • Create using the Rule Service wizard UI (Rule Service -> Create menu).

    The above steps are discussed in detail in section  Exposing Rules as Services.
  2. After deployment, click on List under Services in the main tab of the management console. The service will appear in the Deployed Services page.
  3. Click Banking Service to access the dashboard of the service.
  4. Click Try this service in the Client Operations widget of the dashboard to invoke the Try-it tool.
  5. Click deposit in the left pane of the Try-it tool and issue the following request to make a deposit:

    Code Block
    You would get the following result:
    Code Block
    <message>Deposit was successfully done.5 percentage credits is given because the deposit amount is higher than 1000. Amount was : 2432. Your account balance is now : 2432</message>

    Click withDraw in the left pane of the Try-it tool and issue another request as follows to make a withdrawal:

    Code Block
    You would get the following response:
    Code Block
     <message>Withdraw was successfully done. Amount was : 200. Your new account balance is : 2232</message>

    Alternatively, you can click Generate Axis2 Client in the Client Operations widget of the dashboard to invoke the service. A client using generated stub codes is shown below where the codes were generated with the Unpacks the databinding  classes check box checkedSince this service is an stateful service, the java client which uses the axis2 session management is necessary for proper execution. Execute the axis2 java client found in <BRS_HOME>/samples/clients directory.

  6. Following is the sample that comes with brs clients. Note how the setManageSession(true) is used to enable axis2 session inorder to execute the stateful request.

    Code Block
    package org.wso2.carbon.samples;
    import org.apache.axis2.AxisFault;
    import org.wso2.carbon.samples.bankingService.deposit.Deposit;
    import org.wso2.carbon.samples.bankingService.deposit.DepositAccept;
    import org.wso2.carbon.samples.bankingService.deposit.DepositE;
    import org.wso2.carbon.samples.bankingService.stub.BankingServiceStub;
    import org.wso2.carbon.samples.bankingService.withdraw.*;
    import java.rmi.RemoteException;
    public class BankingServiceTestCase {
        public static void main(String[] args) {
            try {
                BankingServiceStub bankingServiceStub =
                        new BankingServiceStub("http://localhost:9763/services/BankingService");
                DepositE depositRequest = new DepositE();
                Deposit deposit = new Deposit();
                Deposit[] deposits = new Deposit[1];
                deposits[0] = deposit;
                DepositAccept[] results = bankingServiceStub.deposit(deposits);
                String result = results[0].getMessage();
                WithDrawE withDrawRequest = new WithDrawE();
                Withdraw withdraw = new Withdraw();
                Withdraw[] withdraws = new Withdraw[1];
                withdraws[0] = withdraw;
                WithDrawRespone withDrawRespone = bankingServiceStub.withDraw(withdraws);
                WithdrawAccept[] withdrawAccepts = withDrawRespone.getWithdrawAccept();
                WithdrawReject[] withdrawRejects = withDrawRespone.getWithdrawReject();
                String resultWithDraw = withdrawAccepts[0].getMessage();
            } catch (AxisFault axisFault) {
            } catch (RemoteException e) {

    Banking service sample to demonstrate the stateful behavior of a rule session in the WSO2 Business Rules Server.