Versions Compared

Key

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

...

Sample

...

configuration

Table of Contents
maxLevel4
minLevel4

Sample

...

rule definition

Rules

Rule 1 : An order for stocks of Company IBM is accepted only if the number of stocks is higher than 10.
Rule 2 : An order for stocks of Company SUN is accepted only if the stock price is higher than 100 $.
Rule 3 : An order for stocks of Company MSFT is accepted only if the stock price is higher than 50 $ and the number of stocks is lower than 200.

...

There is one fact named Order. OrderAccept and OrderReject are used to capture the result of the service.

Rule

...

service configuration (service.rsl) 

Code Block
languagehtml/xml
titleservice.rsl
<ruleService
        name="OrderApprovalService"
        xmlns="http://wso2.org/carbon/rules"
        targetNamespace="http://com.test/orderApproval">
  <ruleSet>
        <rule resourceType="regular" sourceType="file">orderApprovalRules.drl</rule>
    </ruleSet>
    <operation name="placeOrder">
        <input wrapperElementName="placeOrder" namespace="http://com.test/placeorder">
            <fact elementName="order" namespace="http://com.test/placeorder" type="samples.userguide.PlaceOrder"></fact>
        </input>
        <output wrapperElementName="placeOrderRespone" namespace="http://com.test/placeorder">
            <fact elementName="orderAccept" namespace="http://com.test/placeorder" type="samples.userguide.OrderAccept"></fact>
            <fact elementName="orderReject" namespace="http://com.test/placeorder" type="samples.userguide.OrderReject"></fact>
        </output>
    </operation>
</ruleService>


Executing the

...

service

To execute the sampleservice, run the ant command from the  <PRODUCT_HOME>/samples/quotation.service directory to run the OrderApproval Service.

Info

Before executing this sampleservice, it is recommended that you refer Exposing Rules as Services Exposing Rules as Services which explains in detail the process of writing and deploying a business rule.

...