【问题标题】:WSO2 ESB - How to use resource's property as a URL parameter in In SequenceWSO2 ESB - 如何在序列中使用资源的属性作为 URL 参数
【发布时间】:2023-11-06 14:49:01
【问题描述】:

我正在尝试 RESTful 到 RESTful 的映射。我的终点是http://samples.openweathermap.org/data/2.5/weather?q=London,uk

我将它映射到 http://localhost:8080/get_weather/uk/London

这是我的资源源视图,

<api name="API_1" context="get_weather" hostname="http://localhost" port="8080">
    <resource method="GET" uri-template="/{p1}/{p2}/">
        <inSequence>
            <log level="custom">
                <property name="param1" expression="get-property('uri.var.p1')" />
                <property name="param2" expression="get-property('uri.var.p2')" />
            </log>
            <send>
                <endpoint key="http://samples.openweathermap.org/data/2.5/weather?q{param2},{param1}" />
            </send>
        </inSequence>
    </resource>
</api>

最后我会用curl来发出请求

curl -i -H "Accept: application/json" -X GET http://localhost:8080/get_weather/uk/London

如何使用endpoint中记录的参数?

【问题讨论】:

    标签: wso2esb esb


    【解决方案1】:

    试试这样的:

    <send>
      <endpoint>
        <http method="GET" uri-template="http://samples.openweathermap.org/data/2.5/weather?q={uri.var.p2},{uri.var.p1}"/>
      </endpoint>
    </send>
    

    【讨论】:

      最近更新 更多