使用WSO2 ESB
我需要调用rest服务并迭代其响应以查找嵌套值。通过第一次呼叫的响应,我想呼叫第二个服务并提供从第一个服务收到的数据。
给出下面的配置示例;
似乎我错过了如何从第一次调用中获取数据并将其放置在第二个http端点的后续调用中,如我的第二个Call Mediator发送以下i_param2 = {uri.var.destination}所证明的那样我预期它是i_param2 = 41st&橡木
非常感谢任何建议和观点。
以下是我的API的一小部分,对不起如此冗长,但我想展示服务链,以防它是我的配置导致问题:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/updatebusdisplay" name="UpdateBusDisplay" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" protocol="http" url-mapping="/foo">
<inSequence>
<call>
<endpoint>
<http method="get" trace="disable" uri-template="http://api.translink.ca/rttiapi/v1/stops/50641/estimates?apikey=REMOVED&count=1&timeframe=1440"/>
</endpoint>
</call>
<iterate expression="//Destination" id="it1" preservePayload="true">
<target>
<sequence>
<property description="" expression="//Destination/text()"
name="uri.var.destination" scope="default" type="STRING"/>
<log description="" level="full">
<property expression="get-property('uri.var.destination')" name="property_name"/>
</log>
<call>
<endpoint>
<http method="get" trace="disable" uri-template="http://jupiter.signage.me/WebService/sendCommand.ashx?i_userpass=REMOVED&i_stationId=41&i_command=event&i_param1=nameone&i_param2={uri.var.destination}"/>
</endpoint>
</call>
<log level="full"/>
</sequence>
</target>
</iterate>
</inSequence>
使用wirelog复制控制台,显示每次通话中的值以及第一次通话时的响应,我已删除大部分日志以保持较小(呃):
[2016-01-10 00:45:04,423] DEBUG - wire >> "GET /updatebusdisplay/foo HTTP/1.1[\r][\n]"
[2016-01-10 00:45:04,555] DEBUG - wire << "GET /rttiapi/v1/stops/50641/estimates?apikey=REMOVED&count=1&timeframe=1440 HTTP/1.1[\r][\n]"
...REMOVED...
[2016-01-10 00:45:04,666] DEBUG - wire >> "<NextBuses xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><NextBus><RouteNo>041</RouteNo><RouteName>JOYCE STN/CROWN/UBC </RouteName><Direction>EAST</Direction><RouteMap><Href>http://nb.translink.ca/geodata/041.kmz</Href></RouteMap><Schedules><Schedule><Pattern>EB22</Pattern><Destination>41ST & OAK</Destination><ExpectedLeaveTime>12:48am</ExpectedLeaveTime><ExpectedCountdown>3</ExpectedCountdown><ScheduleStatus>-</ScheduleStatus><CancelledTrip>false</CancelledTrip><CancelledStop>false</CancelledStop><AddedTrip>false</AddedTrip><AddedStop>false</AddedStop><LastUpdate>11:46:02 pm</LastUpdate></Schedule></Schedules></NextBus></NextBuses>"
[2016-01-10 00:45:04,687] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:774ccb2b-4723-4fa9-88a5-13e9eab588e0, Direction: request, property_name = 41ST & OAK, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><NextBuses xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><NextBus><RouteNo>041</RouteNo><RouteName>JOYCE STN/CROWN/UBC </RouteName><Direction>EAST</Direction><RouteMap><Href>http://nb.translink.ca/geodata/041.kmz</Href></RouteMap><Schedules><Schedule><Pattern>EB22</Pattern><ExpectedLeaveTime>12:48am</ExpectedLeaveTime><ExpectedCountdown>3</ExpectedCountdown><ScheduleStatus>-</ScheduleStatus><CancelledTrip>false</CancelledTrip><CancelledStop>false</CancelledStop><AddedTrip>false</AddedTrip><AddedStop>false</AddedStop><LastUpdate>11:46:02 pm</LastUpdate></Schedule></Schedules></NextBus></NextBuses></soapenv:Body></soapenv:Envelope>
[2016-01-10 00:45:04,764] DEBUG - wire << "GET /WebService/sendCommand.ashx?i_userpass=REMOVED&i_stationId=41&i_command=event&i_param1=nameone&i_param2={uri.var.destination} HTTP/1.1[\r][\n]"
答案 0 :(得分:0)
由@JavaMasterRSA确认(非常感谢),问题与我的包含无效字符的数据有关。
以下内容有用URI- template encoding in WSO2 ESB for reserved characters