簡體   English   中英

使用REST我無法遍歷一個呼叫的響應數據並在第二個呼叫調解器中使用

[英]Using REST I am unable to iterate through response data of one call and use in a second call mediator

使用WSO2 ESB

我需要調用rest服務並遍歷其響應以尋找嵌套值。 借助第一個呼叫的響應,我想呼叫第二個服務並提供從第一個服務接收的數據。

給定下面的配置示例;

  • 對第一個服務的調用成功,返回一個或多個目標值
  • 遍歷第一個調用的響應時,我可以通過Log Mediator查看目標數據
  • 調用第二個呼叫調解器不會將我看到的數據放置在第二個端點{uri.var.destination}的日志調解器中

看來我似乎缺少如何從第一個調用中獲取數據並將其放在對第二個http終結點的后續調用中的證據,這是我的第二個調用調解器發送的以下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&amp;count=1&amp;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&amp;i_stationId=41&amp;i_command=event&amp;i_param1=nameone&amp;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 &amp; 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]"

正如@JavaMasterRSA所指出的(非常感謝),該問題與我的數據包含無效字符有關。

以下是WSO2 ESB中用於保留字符的有用的URI模板編碼

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM