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

Useful post on WS-Addressing and Oracle BPEL

Dave Lim

Web Service Addressing is the standard method used in Oracle BPEL processes to support asynchronous two-way routing between processes. This is done by injecting routing data into the message SOAP headers so that the process being called has sufficient context to call back to the invoking service (and where necessary the correct instance of the invoking service) on completion.

In some circumstances it may be desirable to redirect the callback from and an asynchronous call to a completely different process or some other compliant service (such as an EJB or ESB). This can be achieved by directly manipulating the WS-Adressing information in the SOAP header of message invoking the asynchronous call:

1. Create an instance of the WS-Addressing Header

If your service is sing WS-Addressing for callback, it will have imported the associated schema, which will allow you to create a variable of the type WSAReplyToHeader, ie.

<variable name="wsaReplyToHeader"…

View original post 265 more words

How to Publish a message using SOA Suite JMS Adapter

That is a very easy task but can be quite annoying if you don´t know were the right elements are, so here it is:

  1. First of all you have to setup a Queue, in this post if you need it;
  2. Now the SOA Suite communicates with everything through adapters, JMS Adapter in this example, and the adapter is the one responsible for publishing the message so when you want to publish a message, you have to setup a connection from the adapter to the Queue and then your composite to the adapter.
  3. To do that go to your server console and under Deployments, click on the JMS Adapter deployment;
  4. Under Settings, navigate to Configuration -> Outbound Connection Pools;
  5. Click the New button at the Outbound Connection Pool Configuration Table;
  6. Select the oracle.tip.adapter.jms.IJmsConnectionFactory and click Next;
  7. On the JNDI Name field, insert the jndi path you want your composite to access;
  8. Select a Deployment plan and then Finish;
  9. Now back on the Outbound Connection Pools tab, expand the list on Outbound Connection Pool Configuration Table and click on the Connection Pool you have created;
  10. On the properties tab assign a value to the ConnectionFactoryLocation, hit Enter and then save;

Now on your Soa Suite project:

  1. On your composite.xml, drag a JMS Adapter on the External References column;
  2. At the wizard, give the service a name;

    1

  3. On the JMS Provider screen point to Oracle Weblogic JMS if that is your case, like mine;

    1

  4. Next the wizard will ask you for a connection to a server where the queue is, select or create a connection if you need, and then Next;

    1

  5. Unless you already have a contract for your JMS connection, just select Define interface later on your next screen;

    1

  6. On the Produce Operations Screen, select the Queue you are connecting to and on the JNDI name you must type the jndi for the JMS Adapter Connection Pool you create on step 9 previously. Click Next;

    1

  7. Select the Opaque schema on the next screen, unless you already have a schema for your message;

    1

  8. Hit Next then Finish.

 

You can test it forwarding a request to it through a WS request, just like I did:

 

7

 

Thank you!