Вы находитесь на странице: 1из 77

Business Rules Composite

Cookbook on how to create a simple Business Rule Composite in Oracle SOA Suite

Create New SOA Project

Enter Project Name and Directory

Begin with Empty Composite

(or Composite With Business Rule)

Drag Business Rule in the composite.xml, enter Name and Package and click + Input

Define Input Message by importing types from MDS

Do not Copy to Project !

You dont want to have copies of shared xsds (xsds used by multiple composites and/or systems) scattered around in multiple projects. Only xsds which are only used within a composite are stored within a composite project.

Select Input Type

Click + Output

Define Output Message by importing types from MDS

Again do not Copy to Project !

Select Output Type

Select tab Advanced to enter a nice Service Name

Finally Select OK

Open composite

Drag a Mediator to the Components lane, enter Name and select Synchronous Interface

Always use a Mediator to expose to the outside world! It offers routing and mapping flexibility for future changes.

Select as Input same type as Business Rule Engine, so first import types

Again do not Copy to Project !

Select same Input Type

Same applies for output type. Make sure Create Composite Service with SOAP Bindings is checked

Press OK

Drag the arrow of the Mediator to the Rule Engine to wire execute method to callFunctionStateless method

Double click on Mediator and click on button to create a mapping

Provide meaningfull name for the new Mapper file

In the mapper on the right side expand node parameterList, right click on NOM-details and select Add XSL Node > copy-of

Select Replace the selected Node with the results of the copy-of

Drag the NOM-details on the left side to the copy-of

In the mapper on the right click, rightclick on attribute name and select Set Text > Enter Text

Enter text NominationRulesService (name of the service in the business rule engine)

Save all, close mapper, open mediator again and create reply mapping

Copy in the same way VAL-answer from resultList to Val-answer target

Save all, close mapper and mediator and open NominationRules by double click in the composite

Select Ruleset1 and Create Decision Table

Click on the table name to enter a meaningful name

Click on <insert condition>

Double click on C1 <edit condition> and select TNOMDetails.status

Click on ? below R1 and select INITIAL

Click on button Gap Analysis

Select the checkbox to fill the gap

Click on tab Functions

Click on + to create a function and enter Name, select void as Return Type and enter a meaningful Description

Click on <insert action> in the Body part and create the following code:
assert new TVALAnswer( <edit properties> )

Click on <edit properties> and select null and true as constant values

The same for new function validateNOK with null and false as constant values

Dont worry, were gonna fill the error part later on.

Navigate back to DecisionTable NomStatus in Ruleset1, click on <insert action> and select Call

Double click on A1 call( and select function validateOK

Click on + and select Action > Call

Select validateNOK for A2, select A1 as action for R1 and A2 for R2

Test this basic setup by deploying the composite and using soapUI.

Retrieve WSDL url from Test tab in Enterprise Manager.

Create new Project in soapUI with WSDL url

Fill request with test data and invoke

Nominaton status value initial results to true as nomination response

Open NominationRules again and select the Facts tab

Select subtab Java Facts (bottom screen), press + button, browse and search for java.util.ArrayList

Select! (checkbox) and press OK

Select tab Functions and select validateNOK function to change it

Add two arguments of type String with the + button of the Arguments section and name them code and message

With right click next to statement you can delete, insert new statements, etc

Create code for function validateNOK:

Select Ruleset1 and double click on action A2 to edit argument settings

Check Parameterized checkbox for both arguments and press OK

Fill arguments for R2 with code 001 message Invalid Nomination

Deploy and assert arguments are returned in output

In decision table create two more rules and split up R2 into separate values and enter their arguments for A2

If you, by accident provide arguments, for unused A2 call, you can not delete them! Run time this doesnt matter, but you can set them to null value for readability.

Deploy and test again

Select tab Globals and with + button create variable MaxNomAmount of type int, value 10000 and check both Constant and Final

Select tab Bucketsets and with + button create new bucketset of type List of Ranges

Edit this new bucketset by selecting it and the pencil button (or double click on bucketset icon) and first provide a decent name

Use the + button to create 0 value endpoint and again to create Endpoint of Global value MaxNomAmount. Uncheck checkbox Included Endpoint, so MaxNomAmount will be allowed.

Press OK to save the bucketset

Select Ruleset1 again and add condition with + button

Double click on C2 and select TNOMDetails.totalAmount

Select C2 and assign NominationAmountBuckets to it

Set [0..MaxNomAmount] as value for R1 with status INITIAL and OK result

Enter - , a dash, as value for R2-R4 meaning otherwise

Create two rules for status INITIAL with < 0 and > MaxNomAmount buckets, assign validateNOK and provide decent arguments

Deploy and test your end result

Вам также может понравиться