This guide demonstrates a service for getting quotations, which uses business rules for creating quotations.
To run this sample:
- Windows, Linux or Solaris operating system should exist.
- WSO2 BRS should be installed. To install the BRS, refer Installing the Product. This also includes installing Apache Ant as one of the Installation Prerequisites.
- WSO2 BRS should be started as described in Running the Product.
Sample rule definition
Rule 1: If the customer has bronze status, then the item costs five dollars.
Rule 2 : If the customer has silver status, then the item costs four dollars.
Rule 3 : If the customer has gold status, then the item costs three dollars.
There is a fact named
A customer made a get quote request .
Quotation is used to capture the result of the rules execution.
Rule service configuration (service.rsl)
Executing the service
To execute the service, run the
ant command from the
<PRODUCT_HOME>/samples/quotation.service directory to run the GetQuote Service.
Before executing this service, it is recommended that you refer Exposing Rules as Services which explains in detail the process of writing and deploying a business rule.
Deploying and testing the service
- 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.
- After deployment, click on List under Services in the main tab of the management console. The service will appear in the Deployed Services page.
- Click GetQuote Service to access the dashboard of the service.
- Click Try this service in the Client Operations widget of the dashboard to invoke the Try-it tool.
Issue a request similar to the following in the Try-it tool:
You would get the following response:
Alternatively, you can use Generate Axis2 Client link in the
Client Operationswidget 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.