Local-Entries with WSO2 API Manager

Madhuri Bandara
2 min readApr 24, 2020

If you have worked with WSO2 EI / ESB you might familiar with the Local registry which acts as a memory registry that stores static contents. This can be a static text, XML, or URL. The local entries can be referenced from mediators[1].

By default WSO2 API Manager does not contain this feature. I will guide you to create a local entry and reference the properties inside a sequence file. 😊

First, let’s create a folder called “local-entries” inside the <APIM_Home>/repository/deployment/server/synapse-configs/default directory. Then we need to add our file inside this local-entries folder. The below is a sample configuration file (ex: Test.xml). You need to give the localEntry Key as same as the sequence Name.

<?xml version="1.0" encoding="UTF-8"?>
<localEntry xmlns="http://ws.apache.org/ns/synapse" key="Test"><sequence name="Test">
<payloadFactory media-type="xml">
<format xmlns="">
<userName>testuser</userName>
<password>testuser</password>
</format>
</payloadFactory>
</sequence>
<description/>
</localEntry>

Now, we need to create the custom Sequence file which reads the details from the local entries. The below is a sample sequence file.

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="TestSequence">
<property name="Test_Prop" expression="get-property('Test')" scope="default" type="OM"/>
<log level="custom">
<property expression="$ctx:Test_Prop" name="FullValue" />
<property expression="$ctx:Test_Prop//userName" name="Username - "/>
</log>
</sequence>

Since we are accessing values inside an XML file, we need to use type as OM, and scope should be the default.

Now we can apply this sequence to the IN flow of an API and you will see the relevant logs as below. 😇

[2020–04–24 19:09:29,869] INFO — LogMediator FullValue = <sequence xmlns=”http://ws.apache.org/ns/synapse" name=”Test”>
<payloadFactory media-type=”xml”>
<format xmlns=”” >
<userName>testuser</userName>
<password>testuser</password>
</format>
</payloadFactory>
</sequence>, userName — = testuser

This is a manual process. Instead, you can store the files inside the config registry in management console. Let’s see how to do this from a future blog. 🤗

Thank you for reading!!

Reference: [1] https://ei.docs.wso2.com/en/latest/micro-integrator/develop/creating-artifacts/registry/creating-local-registry-entries/

--

--