Tuesday, August 25, 2015

[WSO2 ESB] How to replace message body by a value of a property

Here is how to do it. This will replace message body by the value of "xmlfile" property.

Make sure you set type="OM" in property. Otherwise you will get below error.

"ERROR - EnrichMediator Invalid Object type to be inserted into message body"


Monday, August 24, 2015

[WSO2 ESB] How to read a file from registry and store in a property

Here is how to do it. This will load body.xml file from governance registry, and store in 'xmlfile' property.

Having 'registry' scope is the key here. Type is "OM" because it is an xml file.

Related:
How to read a file from registry

Tuesday, August 18, 2015

How to Split a JSON array in WSO2 ESB

Say you have this JSON array.

Now you want to split users, and call some backend service for each user. Here is how to do. (Here I'm logging each user details instead of calling a backend service.)

Output will look like this.

[2015-08-18 15:49:27,200]  INFO - LogMediator Name is = X, Age is = 10
[2015-08-18 15:49:27,204]  INFO - LogMediator Name is = Y, Age is = 12
[2015-08-18 15:49:27,205]  INFO - LogMediator Name is = Z, Age is = 15

Hope this will be helpful to someone.

References
https://denuwanthi.wordpress.com/2015/06/03/wso2-esbaccess-an-array-defined-in-property-mediator/