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 Shopping 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 addProduct in the left pane of the Try-it tool and issue a request similar to the following in the Try-it tool to add a product:

    Code Block
    <name>product name</name>

    You would get the following result:

    Code Block
    <axis2ns11:addProductResponse xmlns:axis2ns11="http://com.test/shopping"/>

  6. Click purchase in the left pane of the Try-it Tool and issue another request similar to the following to make a purchase:

    Code Block
    <product>Test Product</product>


    The following would be logged in the terminal:

    Code Block
     New Customer : Tester
    Customer Tester just purchased Test Product

    Repeat this step ten times. You would get the following result in the Try-it tool:

    Code Block
  7. Alternatively, you can use Generate Axis2 Client link 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 data binding classes check box checked.

    Code Block
    package org.wso2.carbon.samples;
    import org.apache.axis2.AxisFault;
    import org.wso2.carbon.samples.shoppingService.product.AddProduct;
    import org.wso2.carbon.samples.shoppingService.product.Product;
    import org.wso2.carbon.samples.shoppingService.purchaseOrder.Discount;
    import org.wso2.carbon.samples.shoppingService.purchaseOrder.Purchase;
    import org.wso2.carbon.samples.shoppingService.purchaseOrder.PurchaseOrder;
    import org.wso2.carbon.samples.shoppingService.stub.ShoppingServiceStub;
    import java.rmi.RemoteException;
    public class ShoppingServiceTestCase {
        public static void main(String[] args) {
            ShoppingServiceStub shoppingServiceStub = null;
            try {
                shoppingServiceStub = new ShoppingServiceStub("http://localhost:9763/services/ShoppingService");
                AddProduct addProduct = new AddProduct();
                Product product = new Product();
                Product[] products = new Product[1];
                products[0] = product;
                PurchaseOrder purchaseOrder = new PurchaseOrder();
                Purchase purchase = new Purchase();
                Purchase[] purchases = new Purchase[1];
                purchases[0] = purchase;
                Discount[] discounts = shoppingServiceStub.purchase(purchases);
                int result = discounts[0].getAmount();
            } catch (AxisFault axisFault) {
            } catch (RemoteException e) {

    Shopping service sample of the WSO2 Business Rules Server samples guide.