Versions Compared

Key

  • 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 Exposing Rules as Services.

2. After deployment, the service will appear in the Deployed Services window of the BRS management console. Access the service's dashboard by clicking on it.

3. In the Client Operations widget of the dashboard, invoke the Try-it toolTesting WSDLs (Try-it Tool) to Tool to test the service.

4. In the service's Try-it window, issue a request similar to the following. As the first step, we do a deposit followed by funds withdrawal.

Make a Deposit:

Code Block
languagehtml/xml
<amount>2432</amount>
<accountNumber>330021vc</accountNumber>

Make a withdrawal:

 

Code Block
languagehtml/xml
<amount>200</amount>
<accountNumber>330021vc</accountNumber>

 

Code Block
languagejava
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");
            bankingServiceStub._getServiceClient().getOptions().setManageSession(true);

            DepositE depositRequest = new DepositE();
            Deposit deposit = new Deposit();
            deposit.setAccountNumber("070229x");
            deposit.setAmount(1000);
            depositRequest.addDeposit(deposit);

            Deposit[] deposits = new Deposit[1];
            deposits[0] = deposit;
            depositRequest.setDeposit(deposits);

            DepositAccept[] results = bankingServiceStub.deposit(deposits);
            String result = results[0].getMessage();
            System.out.println(result);

            WithDrawE withDrawRequest = new WithDrawE();
            Withdraw withdraw = new Withdraw();
            withdraw.setAccountNumber("070229x");
            withdraw.setAmount(500);
            Withdraw[] withdraws = new Withdraw[1];
            withdraws[0] = withdraw;
            withDrawRequest.setWithDraw(withdraws);
            WithDrawRespone withDrawRespone = bankingServiceStub.withDraw(withdraws);
            WithdrawAccept[] withdrawAccepts = withDrawRespone.getWithdrawAccept();
            WithdrawReject[] withdrawRejects = withDrawRespone.getWithdrawReject();
            String resultWithDraw = withdrawAccepts[0].getMessage();
            System.out.println(resultWithDraw);

        } catch (AxisFault axisFault) {
                axisFault.printStackTrace();

        } catch (RemoteException e) {
            e.printStackTrace();
        }

    }
}

 

...