cookbook oracle soa business rules

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

Upload: emiel-paasschens

Post on 02-Jun-2015

9.079 views

Category:

Technology


2 download

DESCRIPTION

How to create a simple decision table in Oracle SOA Suite 11g

TRANSCRIPT

Page 1: Cookbook Oracle SOA Business Rules

Business Rules Composite

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

SOA Suite

Page 2: Cookbook Oracle SOA Business Rules

Create New SOA Project

Page 3: Cookbook Oracle SOA Business Rules

Enter Project Name and Directory

Page 4: Cookbook Oracle SOA Business Rules

Begin with Empty Composite

(or Composite With Business Rule)

Page 5: Cookbook Oracle SOA Business Rules

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

Input…

Page 6: Cookbook Oracle SOA Business Rules

Define Input Message by importing types from MDS

Page 7: Cookbook Oracle SOA Business Rules

Do not ‘Copy to Project’ !

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

Page 8: Cookbook Oracle SOA Business Rules

Select Input Type

Page 9: Cookbook Oracle SOA Business Rules

Click + Output…

Page 10: Cookbook Oracle SOA Business Rules

Define Output Message by importing types from MDS

Page 11: Cookbook Oracle SOA Business Rules

Again do not ‘Copy to Project’ !

Page 12: Cookbook Oracle SOA Business Rules

Select Output Type

Page 13: Cookbook Oracle SOA Business Rules

Select tab Advanced to enter a nice Service Name

Page 14: Cookbook Oracle SOA Business Rules

Finally Select OK

Page 15: Cookbook Oracle SOA Business Rules

Open composite

Page 16: Cookbook Oracle SOA Business Rules

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.

Page 17: Cookbook Oracle SOA Business Rules

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

Page 18: Cookbook Oracle SOA Business Rules

Again do not ‘Copy to Project’ !

Page 19: Cookbook Oracle SOA Business Rules

Select same Input Type

Page 20: Cookbook Oracle SOA Business Rules

Same applies for output type.Make sure “Create Composite Service

with SOAP Bindings” is checked

Page 21: Cookbook Oracle SOA Business Rules

Press OK

Page 22: Cookbook Oracle SOA Business Rules

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

callFunctionStateless method

Page 23: Cookbook Oracle SOA Business Rules

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

Page 24: Cookbook Oracle SOA Business Rules

Provide meaningfull name for the new Mapper file

Page 25: Cookbook Oracle SOA Business Rules

In the mapper on the right side expand node parameterList, right click on NOM-

details and select Add XSL Node > copy-of

Page 26: Cookbook Oracle SOA Business Rules

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

Page 27: Cookbook Oracle SOA Business Rules

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

Page 28: Cookbook Oracle SOA Business Rules

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

Enter Text…

Page 29: Cookbook Oracle SOA Business Rules

Enter text “NominationRulesService” (name of the service in the business rule

engine)

Page 30: Cookbook Oracle SOA Business Rules

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

Page 31: Cookbook Oracle SOA Business Rules

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

Page 32: Cookbook Oracle SOA Business Rules

Save all, close mapper and mediator and open NominationRules by double

click in the composite

Page 33: Cookbook Oracle SOA Business Rules

Select Ruleset1 and Create Decision Table

Page 34: Cookbook Oracle SOA Business Rules

Click on the table name to enter a meaningful name

Page 35: Cookbook Oracle SOA Business Rules

Click on <insert condition>

Page 36: Cookbook Oracle SOA Business Rules

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

Page 37: Cookbook Oracle SOA Business Rules

Click on ? below R1 and select INITIAL

Page 38: Cookbook Oracle SOA Business Rules

Click on button Gap Analysis…

Page 39: Cookbook Oracle SOA Business Rules

Select the checkbox to fill the gap

Page 40: Cookbook Oracle SOA Business Rules

Click on tab Functions

Page 41: Cookbook Oracle SOA Business Rules

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

and enter a meaningful Description

Page 42: Cookbook Oracle SOA Business Rules

Click on <insert action> in the Body part and create the following code:

assert new TVALAnswer( <edit properties> )

Page 43: Cookbook Oracle SOA Business Rules

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

Page 44: Cookbook Oracle SOA Business Rules

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

Don’t worry, we’re gonna fill the error part later on.

Page 45: Cookbook Oracle SOA Business Rules

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

select Call

Page 46: Cookbook Oracle SOA Business Rules

Double click on ‘A1 call(’ and select function validateOK

Page 47: Cookbook Oracle SOA Business Rules

Click on + and select Action > Call

Page 48: Cookbook Oracle SOA Business Rules

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

Page 49: Cookbook Oracle SOA Business Rules

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

Retrieve WSDL url from Test tab in Enterprise Manager.

Page 50: Cookbook Oracle SOA Business Rules

Create new Project in soapUI with WSDL url

Page 51: Cookbook Oracle SOA Business Rules

Fill request with test data and invoke

Page 52: Cookbook Oracle SOA Business Rules

Nominaton status value ‘initial’ results to true as nomination response

Page 53: Cookbook Oracle SOA Business Rules

Open NominationRules again and select the Facts tab

Page 54: Cookbook Oracle SOA Business Rules

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

java.util.ArrayList

Page 55: Cookbook Oracle SOA Business Rules

Select! (checkbox) and press OK

Page 56: Cookbook Oracle SOA Business Rules

Select tab Functions and select validateNOK function to change it

Page 57: Cookbook Oracle SOA Business Rules

Add two arguments of type String with the + button of the Arguments section

and name them code and message

Page 58: Cookbook Oracle SOA Business Rules

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

Page 59: Cookbook Oracle SOA Business Rules

Create code for function validateNOK:

Page 60: Cookbook Oracle SOA Business Rules

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

Page 61: Cookbook Oracle SOA Business Rules

Check Parameterized checkbox for both arguments and press OK

Page 62: Cookbook Oracle SOA Business Rules

Fill arguments for R2 with code “001” message “Invalid Nomination”

Page 63: Cookbook Oracle SOA Business Rules

Deploy and assert arguments are returned in output

Page 64: Cookbook Oracle SOA Business Rules

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 doesn’t matter, but you can set them to null value for readability.

Page 65: Cookbook Oracle SOA Business Rules

Deploy and test again

Page 66: Cookbook Oracle SOA Business Rules

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

Page 67: Cookbook Oracle SOA Business Rules

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

Ranges”

Page 68: Cookbook Oracle SOA Business Rules

Edit this new bucketset by selecting it and the pencil button

(or double click on bucketset icon) and first provide a decent name

Page 69: Cookbook Oracle SOA Business Rules

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.

Page 70: Cookbook Oracle SOA Business Rules

Press OK to save the bucketset

Page 71: Cookbook Oracle SOA Business Rules

Select Ruleset1 again and add condition with + button

Page 72: Cookbook Oracle SOA Business Rules

Double click on C2 and select TNOMDetails.totalAmount

Page 73: Cookbook Oracle SOA Business Rules

Select C2 and assign NominationAmountBuckets to it

Page 74: Cookbook Oracle SOA Business Rules

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

Page 75: Cookbook Oracle SOA Business Rules

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

Page 76: Cookbook Oracle SOA Business Rules

Create two rules for status INITIAL with < 0 and > MaxNomAmount buckets,

assign validateNOK and provide decent arguments

Page 77: Cookbook Oracle SOA Business Rules

Deploy and test your end result