Extract Human Task Event payload detail in SOA Mediator

Oracle SOA/BPM Human Task provides a very powerful feature to generate Business Event upon a task assignment or completion. The associated Business Event will then be sent to the Oracle Event Delivery Network and it can be captured by a Mediator component, which in turn executes others services or processes, like creating a Microsoft Exchange Task with Reminder as nicely described from this blog entry.


When the information that you need from the Business Event is only related to the Task metadata (taskid, assignee, taskURL…) then the configuration is pretty straight forward as it is possible to extract each desired element easily from the XSL mapping tools. And there are plenty of blogs out there showing the step by step configuration for this purpose.


However, if you need to extract a specific ‘value’ from the Task payload, the picture suddenly becomes more complicated as the ‘payload’ element in the Business Event has a xsd:anyType type and it is not possible to “browse” the payload detail, hence mapping them out easily from the XSL Mapping tool in Jdeveloper for further processing.


To address to the problem there are 2 options: 



  1. (Easy but Restrictive) Map the specific values to be catch using the Human Task Mapped Attributes (or directly in the systemMessageAttributes in the execData). When doing so those values can not only be used for queries from BPM Workspace, and they will be mapped as the Task metadata so you can easily link them up during the XSL transformation. Nevertheless, every time you want to extract additional values, the Human Task has to be modified and the associated process needs to be redeployed. It is a valid option if you know exactly what you need upfront.

  2. (Relatively difficult but flexible) Fully utilize XSL Transformation capability to extract the “hidden” values from the payload element. This option requires more XML/XSL knowledge and not necessarily easy to comprehend. However it provides much more flexibility and it can have a completely independent design lifecycle from the original business process. This is the option we will explore in this post. If you want to get before hand the source code of the example below, you can download from here.




First of all, consider the following BPM Process with a very simple Human Task taking 2 Data arguments defined by the Business Object FirstBO and SecondBO. Please note a third Business Object ThirdBO is encapsulated within SecondBO.






Now let’s enable the Human Task to generate a Business Event upon the task assignment. To do this, open the Human Task, go to Event and check the box OnAssigned (Please note the other available option but there are not key in our current demonstration)



From the Business Process perspective we are all set. Now let’s consider the a separate SOA Composite Application which only contains a Mediator to capture the associated business event and an File Adaptor to extract write data into a file.



Once we link the Mediator to the File Adaptor, we can then generate a XSL stylesheet to transform the Human Task Event into service call to write data into a file. 



Now the challenge is to extract the Payload information within the stylesheet. This can be done via the XSL source mode with 3 major steps:



  1. Add all the namespace of the objects within the payload. Those namespaces can be retrieved either directly from the BO definition or the Human Task configuration page

  2.       xmlns:p1="http://xmlns.oracle.com/bpm/bpmobject/Data/FirstBO"
          xmlns:p2="http://xmlns.oracle.com/bpm/bpmobject/Data/SecondBO"
          xmlns:p3="http://xmlns.oracle.com/bpm/bpmobject/Data/SubData/ThirdBO"

     


  3. Create XSL variables, pointing to a specific argument of the Human Task with the Payload, using the namespaces defined above. In our case we have 2 arguments so we create 2 variables

  4. <xsl:variable name="">p1:firstPayload
    select="/tns:taskAssignedMessage/task:task/task:payload/p1:FirstBO"/>
    <xsl:variable name="p2:secondPayload"
    select="/tns:taskAssignedMessage/task:task/task:payload/p2:SecondBO"/>

  5. Finally, you can now manually extract each desired value from the XSL variable by using the XPath expression

  6.       
          <imp1:FirstBO.one>
            <xsl:value-of select="$p1:firstPayload/p1:one"/>
          </imp1:FirstBO.one>
          <imp1:FirstBO.two>
            <xsl:value-of select="$p1:firstPayload/p1:two"/>
          </imp1:FirstBO.two>
          <imp1:FirstBO.three>
            <xsl:value-of select="$p1:firstPayload/p1:three"/>
          </imp1:FirstBO.three>
          <imp1:SecondBO.one>
            <xsl:value-of select="$p2:secondPayload/p2:one"/>
          </imp1:SecondBO.one>
          <imp1:SecondBO.two>
            <xsl:value-of select="$p2:secondPayload/p2:two"/>
          </imp1:SecondBO.two>
          <imp1:SecondBO.three.ThirdBO.one>
            <xsl:value-of select="$p2:secondPayload/p2:three/p3:one"/>
          </imp1:SecondBO.three.ThirdBO.one>
          <imp1:SecondBO.three.ThirdBO.two>
            <xsl:value-of select="$p2:secondPayload/p2:three/p3:two"/>
          </imp1:SecondBO.three.ThirdBO.two>

To get a complete view of the final XSL stylesheet, please download the source code of the 2 projects illustrated from here.

Now you can deploye both projects into your BPM domain, and you can initiate the SampleProcess to start the testing:



After the execution, monitor the process thread in FMW Control and you should see the execution on the Mediator upon the Human Task initialization. 




By clicking on the Mediator link you will be able to see the payload retrieved by the Mediator (Business Event):




And of course the transformed payload using the XSL Stylesheet we specified above:





Voilà ! Hope this entry is useful to you.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Hi, I am Manh-Kiet Yap (known as Kiet @oracle) and I'm currently the Technical Director at the APAC Advanced Customer Services.

I've recently received my 15 years of long service award, after being successively Technical Consultant in France, Presales at Hong Kong, FMW Product Manager in EMEA, Presales Mgr in APAC and finally Architect at Oracle ACS.

With my 15 years experience around Middleware, I hope you will find this blog valuable if you are navigating around Oracle Fusion Middleware !

View Manh-Kiet Yap's profile on LinkedIn

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today