1

I configured Proxy Service parameter according to the documentation:

<proxy xmlns="http://ws.apache.org/ns/synapse" name="CQProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
       ...
   </target>
   <parameter name="TestParam">ParamValue1</parameter>
</proxy>

Now I need to access it from within the sequence. Is there any way to do it?

I tried accessing it using script mediator:

 <script language="js">mc.setProperty("TestParamProp", mc.getParameter("TestParam"))</script>

but it throws "Cannot find function getParameter." error.

Please advice.

Community
  • 1
  • 1
Alex Yakimovich
  • 259
  • 1
  • 4
  • 17

2 Answers2

2

use the following to access the ESB params from the script mediator

<script language="js"> var test_param = mc.getProperty('TestParam') </script>

Use the following to retrieve the params within the script mediator back to the ESB

mc.setProperty("newParam",test_param)
Nadeesha
  • 825
  • 2
  • 9
  • 12
  • This clause will access Properties not Parameters – Alex Yakimovich Jul 09 '13 at 19:56
  • This is not possible please refer to the following URL[1]. You can achieve this by setting the parameter and the property at the same time and pass the property value to the script mediator. [1]http://stackoverflow.com/questions/17562087/how-to-get-the-property-transport-vfs-fileuri-in-sequence-wso2 – Nadeesha Jul 10 '13 at 08:30
  • Yes, it looks like there is no clear way to access Proxy Service parameter from within a sequence. Thanks! – Alex Yakimovich Jul 10 '13 at 12:44
  • You can set it as a property and access – Nadeesha Jul 11 '13 at 08:34
0

Give the input in json format and try the code given below,

<property name="TestParam" expression="json-eval($.TestParam)"></property>
<script language="js">
mc.setProperty("TestParamProp", mc.getProperty("TestParam"));
</script>