我有一个端点:http://localhost:8080/customer/get/1
我想将一个 json 数据发送到 wso2esb 中的 api 并将 id 的值转换为路径变量并将其发送到端点。像这样:
{"id":"1"}
我该怎么做?请给我一些建议。
您应该构建 Uri 模板路径,其属性以前缀uri.var命名。例如命名:uri.var.myId。并从 JSON 中提取有趣的值。接下来,您可以在括号中的 uri-template 中的 http 端点中使用该属性。
对于您的示例,您正在寻找的是这样的:
<property name="uri.var.myId" expression="json-eval($.id)" scope="default" type="STRING"/>
<call>
<endpoint>
<http uri-template="http://localhost:8080/customer/get/{uri.var.myId}"/>
</endpoint>
</call>
在wso2esb 4.9.0 文档中有更精确的描述
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句