我是 WSO2 esb 的新手。我想创建一个 api,我想在其中添加一个从 api Url 到端点 url 的动态参数。
我的终点网址就像 http://example.com/api/sync/{session_id}.json
我试图创建像
<api name="rest" context="/sync">
<resource methods="GET" uri-template="/{id}">
<inSequence>
<log level="full">
<property xmlns:ns="http://org.apache.synapse/xsd"
name="uri.var.session"
expression="get-property('uri.var.id')"
scope="axis2"/>
</log>
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
<send>
<endpoint name="Mecars">
<http trace="enable"
method="get"
uri-template="http://example.com/sync/{+uri.var.session}.json"/>
</endpoint>
</send>
</inSequence>
</resource>
</api>
在日志中,我得到了 uri.var.session 的值但在端点 Uri-template 上它没有附加。
请指导我如何将 api uri-template 中的 {id} 值附加到端点 uri-template?
最佳答案
检查这个 sample
我建议您在属性中介处进行字符串连接,然后直接在 uri-template 中使用它,而不是在 uri-template 中添加“variable +.json”。
那是;
<property xmlns:ns="http://org.apache.synapse/xsd"
name="uri.var.session"
expression="get-property('uri.var.id')"
scope="axis2"/>
在上面的 for 表达式中,进行字符串连接以构造以“.json”结尾的完整变量。
关于wso2 - 将参数添加到端点 url wso2 esb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19906283/