Friday, October 13, 2017

Get Set Properties in BPEL header / Passing Properties from 1 BPEL and receiving in another BPEL using header

Hi Guys,

I am writing this post, because one day, I wanted to pass few properties from my bpel, which I needed in 2nd bpel process. I coudn't find any blogs with full details. There were many with partial details about how to do it.


Use Case :
Properties of 1st bpel needs to be passed to 2nd bpel. These could be timestamp, any unique ID genrated in bpel 1, or File name or location in case of file/ftp adapter service etc.


Implementation :
There could be many ways, how you do this, however one of the simplest way to achieve this is using the properties. High level steps :
1. Add the properties while invoking the reference Paternelink
2. Fetch the properties from received payload.

Note : The Syntax is different for bpel 1.1 and bpel 2.0, Most blogs has this for bpel 1.1 in their posts. This post is based on bpel 2.0


STEP 1 :
Add properties in your Invoke.



Source code view--




STEP 2:
Add properties in your receive activity of 2nd bpel


 Source code view--




Thats all.


Testing, screens from the Flow trace.

1st bpel invoke --



2nd bpel receive --



It is not only INVOKE and RECEIVE activities where you can use , but others supported activities are listed below with their format:

BPEL 2.0 bpelx Extensions Syntax
The following example shows bpelx extensions syntax in BPEL 2.0:
<invoke ...>
  <bpelx:fromProperties>?
    <bpelx:fromProperty name="NCName" .../>+
  </bpelx:fromProperties>
  <bpelx:toProperties>?
    <bpelx:toProperty name="NCName" .../>+
  </bpelx:toProperties>
</invoke>

<receive ...>
  <bpelx:fromProperties>?
    <bpelx:fromProperty name="NCName" .../>+
  </bpelx:toProperties>
</receive>

<onEvent ...>
  <bpelx:fromProperties>?
    <bpelx:fromProperty name="NCName" .../>+
  </bpelx:fromProperties>
</onEvent>

<reply...>
  <bpelx:toProperties>?
    <bpelx:toProperty name="NCName" .../>+
  </bpelx:toProperties>
</reply>

<reply ...>
  <bpelx:toProperties>
    <bpelx:toProperty name="NCName" .../>
  </bpelx:toProperties>
</reply>
Note the following details:
  • The toProperty is a from-spec. This copies a value from the from-spec to the property of the given name.
  • The fromProperty is a to-spec. This copies a value from the property to the to-spec.



BPEL 1.1 bpelx Extensions Syntax

The following example shows bpelx extensions syntax in BPEL 1.1:
<invoke ...>
  <bpelx:inputProperty name="NCName" expression="string" variable="NCName"
 part="NCName" query="string"/>*
  <bpelx:outputProperty name="NCName" expression="string" variable="NCName"
 part="NCName" query="string"/>*
</invoke>

<receive ...>
  <bpelx:property name="NCName" expression="string" variable="NCName"
 part="NCName" query="string"/>*
</receive>

<onMessage...>
  <bpelx:property name="NCName" expression="string" variable="NCName"
 part="NCName" query="string"/>*
</onMessage>

<reply ...>
  <bpelx:property name="NCName" expression="string" variable="NCName"
 part="NCName" query="string"/>*
</reply>  


Refer Oracle Doc for more detail, available at -- http://docs.oracle.com/middleware/12213/soasuite/develop/GUID-33A38C1A-38A6-473B-9FEA-D3164AD7A118.htm#SOASE87180