Wednesday, August 15, 2007

Modifying XML records dynamically in BPEL

When you use an adapter to retrieve data from the database or reading records from a file, you will get a collection of XML records. Often you want to modify data within this list of XML records. This can be done like the the BPELX:InsertAfter/BPELX: and other functions. But there is another way to to this.

To dynamically change the value of element in a XML record you can manipulated the 'to:' element in the copy clause:

Normally you have:

<copy>
<from variable="InputVariable"
part="payload"
query="/ns1:HelloWorldRequest/ns1:input"/>
<to variable="OutputVariable"
part="payload"
query="/ns1:HelloWorldRequest/ns1:ListOfOrders
/ns1:Order:/ns1:Amount"/>
</copy>
This statement will fail if the the XML payload contains more than one row. Because the assigment is done on a single record. If we use a record counter that loops through this XML payload we are able to assign the specific record very easily. You can change copy in:

<copy>
<from variable="InputVariable"
part="payload"
query="/ns1:HelloWorldRequest/ns1:input"/>
<to variable="OutputVariable"
part="payload"
query="/ns1:HelloWorldRequest/ns1:ListOfOrders[$RecordCounter]
/ns1:Order:/ns1:Amount"/>
</copy>

The trick is to add the [$RecordCounter] directly in in the XPATH query of the copy activity. The BPEL PM will interprete this and translate this into the correct value.

Note: You must define the variable "RecordCounter" in your scope as an integer.

Wednesday, August 01, 2007

10.1.3.3 and the samples

This is an open door, but when you apply the patch of the 10.1.3.3 SOA Suite, keep in mind that not only the core code has been changed but also the samples. In my case I was struggling with the sample work list application. Later I found out that this sample was also updated. Verify also, when you are using 10.1.3.3 that the documentation could be out of sync on some detail steps.