I solved my question using a different approach. This matches the answer given by bij fipries.
In the proxy, I added the following:
<property name="MAPPING" expression="get-property('mapping_id_ep_v1')" /> <property name="LOOK_UP" expression="//controlFile/id" /> <log level="custom"> <property name="MAPPING" expression="get-property('MAPPING')" /> <property name="LOOK_UP" expression="get-property('LOOK_UP')" /> </log> <script language="js" key="testScript_2" function="getEndpointByID" /> <log level="custom"> <property name="EP" expression="get-property('EP')" /> </log>
This is the contents of mapping_id_ep_v1:
<mappings> <mapping id="ep_1">http://localhost:8280/services/ep_1</mapping> <mapping id="ep_2">http://localhost:8280/services/ep_2</mapping> <mapping id="ep_3">http://localhost:8280/services/ep_3</mapping> <mappings>
This is the code in TestScript_2:
<x> function getEndpointByID(mc) { var xml = new XML(mc.getProperty('MAPPING')); var look_up = new XML(mc.getProperty('LOOK_UP')); var ep = xml..mapping.(@id == look_up); mc.setProperty('EP', ep + ''); } </x>
The proxy loads the xml mapping into the property. This property is converted into XML into javascript code, and then the correct endpoint is retrieved using LOOK_UP.
Hope this helps someone else.
Regards, nidkil
source share