我想在HTTP端點中外部化主機名和端口號,所以我想在JVM參數中傳遞主機名和端口號啓動ESB。 使用腳本/類中介,我可以從系統屬性中獲取它並將其放入消息上下文中。然後使用屬性介體,我可以訪問並記錄它的值。 到此爲止,我沒有任何問題,但是當我嘗試使用此值替換下面的HTTP端點時;它不起作用。WSO2 ESB REST API - 動態HTTP端點(使用模板端點)Externalise - 主機名和端口號
實際ESB突觸API配置:
<api xmlns="http://ws.apache.org/ns/synapse" name="ContentLength" context="/content">
<resource methods="GET">
<inSequence>
<send>
<endpoint>
<http method="get" uri-template="http://198.160.1.223:8080/greeting/{uri.var.name}"></http>
</endpoint>
</send>
</inSequence>
<outSequence>
<send></send>
</outSequence>
</resource>
</api>
預期ESB突觸API配置:
<api xmlns="http://ws.apache.org/ns/synapse" name="ContentLength" context="/content">
<resource methods="GET">
<inSequence>
<script language="js">mc.setProperty("system.hostname",java.lang.System.getProperty("my.hostname"));mc.setProperty("system.port.no",java.lang.System.getProperty("my.port.no"));</script>
<log level="custom">
<property name="system.hostname" expression="get-property('system.hostname')"/>
<property name="system.port.no" expression="get-property('system.port.no')"/>
</log>
<send>
<endpoint>
<http method="get" uri-template="http://{system.prop.my.hostname}:{system.prop.my.port.no}/greeting/{uri.var.name}"></http>
</endpoint>
</send>
</inSequence>
<outSequence>
<send></send>
</outSequence>
</resource>
</api>
有什麼辦法,我可以在此使用模板端點和HTTP終結場景?
讓我知道替代選項。
謝謝Ragavan。有效。我錯過了uri模板變量必須以uri.var開頭的點。 [HTTP端點允許您使用類似於REST API的URI模板來定義REST端點。 URI模板允許RESTful URI包含可以在中介運行時期間使用其名稱具有「uri.var」的屬性值填充的變量。字首。 HTTP端點還可以定義在RESTful調用中使用的特定HTTP方法。] –