2013-06-21 69 views
1

訪問服務參數我根據文檔配置代理服務參數:如何從WSO2 ESB序列

<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> 

現在我需要從序列中訪問它。有什麼辦法可以做到嗎?

我嘗試使用它腳本中介訪問:

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

,但它會拋出「無法找到函數的getParameter。」錯誤。

請指教。

+0

你檢查了mc.getParameter(「$ ctx:TestParam」)嗎? –

+0

它也不工作。問題是無法識別mc.getParameter()函數。 –

回答

2

使用以下方法來從腳本中介

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

使用訪問ESB PARAMS下面的腳本中介內檢索PARAMS回ESB

mc.setProperty("newParam",test_param) 
+0

本條款將訪問屬性不參數 –

+0

這是不可能的請參考以下URL [1]。您可以通過同時設置參數和屬性並將屬性值傳遞給腳本中介來實現此目的。 [1] http://stackoverflow.com/questions/17562087/how-to-get-the-property-transport-vfs-fileuri-in-sequence-wso2 – Nadeesha

+0

是的,它看起來像沒有明確的方式來訪問代理序列內的服務參數。謝謝! –

0

給JSON中輸入格式並嘗試下面給出的代碼,

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