OBR: Returning lists on your rule

Based on the XSD below, I will show you how to create a OBR based on it, receiving the Input element ans returning a ResultList:

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="https://vrsbrazil.wordpress.com/Facts"
targetNamespace="https://vrsbrazil.wordpress.com/Facts"
elementFormDefault="qualified">
<xsd:element name="Input">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="code" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Result">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ResultList">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="tns:Result" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

Here is what you have to do:

  1. First of all, create your SOA project and write the Facts.xsd file on the xsd folder;
  2. On the composite, create the rule named ListReturnRule assigning the input as the Input element and the Output as the ResultList element;
    1
  3. Double click the rule to edit it;
  4. Now on the Decision Function tab, edit your function;
  5. On the Initial Actions tab assert a new ResultList fact;
    2
  6. Now what I like to do is create a function that will fill out the data I need for every fact I will use, so we will create a function to initialize a Result fact, to do that, go to the Functions tab;
  7. Add a new function called createResult with one parameter called description, returning Result;
  8. Inside it assign a new Result and modify it to add the description received;
  9. Return the result;
    3
  10. Now create another function called addResult that receives ResultList and Result as parameters and returns void;
  11. Add the Result into the ResultList using ResultList.result.append(<Object>);
    4
  12. Go back to the Ruleset to edit it;
  13. Create a new IF/THEN rule;
  14. Add the code just like you see in the picture below:
    5
  15. Back on the composite, create a new web-service to test it and you are all done!
  16. Here is some test evidence for you and a source download link:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:lis="http://xmlns.oracle.com/ListReturnRule/ListReturnRule_DecisionService_1" xmlns:bpel="http://xmlns.oracle.com/bpel" xmlns:fac="https://vrsbrazil.wordpress.com/Facts">
 <soapenv:Header/>
 <soapenv:Body>
 <lis:callFunctionStateless name="ListReturnRule_DecisionService_1">
 <lis:parameterList>
 <fac:Input>
 <fac:code>TEST</fac:code>
 </fac:Input>
 </lis:parameterList>
 </lis:callFunctionStateless>
 </soapenv:Body>
</soapenv:Envelope>


&nbsp;

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
 <env:Header>
 <wsa:MessageID>urn:106332606B2311E2BFCD73B009C82809</wsa:MessageID>
 <wsa:ReplyTo>
 <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
 <wsa:ReferenceParameters>
 <instra:tracking.ecid xmlns:instra="http://xmlns.oracle.com/sca/tracking/1.0">c0a4f2fc6a057aaf:-7dab16c5:13c8cd09a1f:-8000-0000000000002dd0</instra:tracking.ecid>
 <instra:tracking.parentComponentInstanceId xmlns:instra="http://xmlns.oracle.com/sca/tracking/1.0">decision:6ed26fd0-93bd-4324-9f8c-dd1f30ec36f6</instra:tracking.parentComponentInstanceId>
 <instra:tracking.compositeInstanceCreatedTime xmlns:instra="http://xmlns.oracle.com/sca/tracking/1.0">2013-01-30T19:21:51.527-02:00</instra:tracking.compositeInstanceCreatedTime>
 </wsa:ReferenceParameters>
 </wsa:ReplyTo>
 <wsa:FaultTo>
 <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
 <wsa:ReferenceParameters>
 <instra:tracking.ecid xmlns:instra="http://xmlns.oracle.com/sca/tracking/1.0">c0a4f2fc6a057aaf:-7dab16c5:13c8cd09a1f:-8000-0000000000002dd0</instra:tracking.ecid>
 <instra:tracking.parentComponentInstanceId xmlns:instra="http://xmlns.oracle.com/sca/tracking/1.0">decision:6ed26fd0-93bd-4324-9f8c-dd1f30ec36f6</instra:tracking.parentComponentInstanceId>
 <instra:tracking.compositeInstanceCreatedTime xmlns:instra="http://xmlns.oracle.com/sca/tracking/1.0">2013-01-30T19:21:51.527-02:00</instra:tracking.compositeInstanceCreatedTime>
 </wsa:ReferenceParameters>
 </wsa:FaultTo>
 </env:Header>
 <env:Body>
 <callFunctionStatelessDecision xmlns="http://xmlns.oracle.com/ListReturnRule/ListReturnRule_DecisionService_1" xmlns:ns2="http://xmlns.oracle.com/bpel">
 <resultList>
 <ResultList:ResultList xmlns:ResultList="https://vrsbrazil.wordpress.com/Facts" xmlns="https://vrsbrazil.wordpress.com/Facts">
 <Result>
 <description>Test1</description>
 </Result>
 <Result>
 <description>Test2</description>
 </Result>
 </ResultList:ResultList>
 </resultList>
 </callFunctionStatelessDecision>
 </env:Body>
</env:Envelope>

OBRExample

Thank you!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s