Wednesday, August 17, 2016

[WSO2 ESB] Use of Local Entries.

In this post I would like to discuss about the importance of local entries used in WSO2 ESB. Local entry is a memory registry.

Assume that you have an element which is used inside the XML configuration in a proxy service or sequence. And the value of this element needs to be changed time to time. In a case like this if you insert this in a local entry you can easily edit, delete or add values to that without changing the entire code.

Local entries are globally visible. So we can retrieve them from anywhere within the system.

There are three types of local entries in WSO2 ESB.
  1. In-lined Text Entry
  2. In-lined XML Entry
  3. Source URL Entry
In-lined Text Entry

In here we can add any text entry. For example if we want to add a name or number which has a high probability of changing time to time, we can add it as a in-lined text entry. And then we can retrieve this value inside the XML configuration and use it.

In-lined XML Entry

In here we can add XML entries.

Source URL Entry

This is for adding URLs as local entries. If that url contains a payload to be retrieved we can get that payload simply by retrieving the value of the local entry.

Retrieving local entries within the XML configuration

We can retrieve these values by writing a XPATH function like this. Assume the name of the local entry is "localEntry".

<property name="LocalEntryValue" expression="get-property('localEntry')"/>

Assume you have a XSLT function to be executed. In a case like this we can add a xsl:stylesheet in a local entry and call it from the source code (XML configuration of sequence/proxy or API). You can even pass parameters for this xslt function.

Here I have stated an example which calls a xslt function saved in an in-lined local entry. It is saved as "test.xsl". Key of this local entry can be specified wherever a registry key is expected in the configuration.

In the following example I have stated the way of calling the local entry and pass a property as a parameter to the xslt function.

 <xslt key="test.xsl">
        <property name="date_time" value="2016-05-24"/>
</xslt>



No comments:

Post a Comment