简体   繁体   English

WSO2 ESB 迭代 DSS 响应(json 数组)

[英]WSO2 ESB Iterate over DSS response (json array)

I have a problem to iterate over call response of a dss.我在迭代 dss 的呼叫响应时遇到问题。 I have 2 servers我有2台服务器

WSO2 ESB server (4.9.0) WSO2 Application Server (5.3.0) with Data Service (4.3.4) feature installed安装了数据服务 (4.3.4) 功能的 WSO2 ESB 服务器 (4.9.0) WSO2 应用程序服务器 (5.3.0)

i make a payload我做一个有效载荷

  <payloadFactory media-type="xml">
    <format>
      <p:valoresReport xmlns:p="ReportsDataService">
        <xs:uuid xmlns:xs="ReportsDataService">$1</xs:uuid>
      </p:valoresReport>
    </format>
    <args>
      <arg value="123456789"/>
    </args>
  </payloadFactory>

and do a call through an endpoint并通过端点进行呼叫

  <call blocking="true">
    <endpoint key="ReportsDataServiceEndPoint"/>
  </call>

The response is:回应是:

<ReportRowSet xmlns="ReportsDataService">
   <reportRow>
      <column1>1</column1>
      <column2>2</column2>
      <column3>3</column3>
   </reportRow>
   <reportRow>
      <column1>columna 1</column1>
      <column2>olumna 2</column2>
      <column3>columna 3</column3>
   </reportRow>
</ReportRowSet>

To read the response, i change de messageType to json要阅读响应,我将 de messageType 更改为 json

  <property name="messageType" scope="axis2" type="STRING" value="application/json"/>

and get the value with json-eval.并使用 json-eval 获取值。

  <property expression="json-eval($.ReportRowSet.reportRow)" name="rows"
    scope="default" type="STRING"/>

I can log the property我可以记录财产

  <log level="custom">
    <property expression="$ctx:rows" name="ROWS"/>
  </log>

output:输出:

[2016-05-31 16:21:38,489]  INFO - LogMediator ROWS = [{"column1":1,"column3":3,"column2":2},{"column1":"columna 1","column3":"columna 3","column2":"olumna 2"}]

But when i try to iterate the rows, i dont know how to do this (this way does not work)但是当我尝试迭代行时,我不知道该怎么做(这种方式不起作用)

 <iterate continueParent="true" expression="$ctx:rows"
    id="MyIterator" sequential="true">
    <target>
      <sequence>
      ...

also i tried with no success (without changing the messagetype):我也尝试过但没有成功(没有改变消息类型):

  <iterate continueParent="true" expression="//ReportRowSet/reportRow"
    id="MyIterator" sequential="true">

whats the correct form to do this integration and iteration.进行这种集成和迭代的正确形式是什么。

I let you my dss and sequence:我让你我的 dss 和序列:

ReportsDataService.dbs: [ https://drive.google.com/open?id=0B44t8SdKZz79ellKVmpkM0t6Rmc ] ReportsDataService.dbs:[ https://drive.google.com/open?id=0B44t8SdKZz79ellKVmpkM0t6Rmc ]

GenerarReporteSequence.xml: [ https://drive.google.com/open?id=0B44t8SdKZz79YlkxMnNnNm8weGs ] GenerarReporteSequence.xml:[ https://drive.google.com/open?id=0B44t8SdKZz79YlkxMnNnNm8weGs ]

Try with proper namespace in your iterator mediator, sample below,尝试在迭代器介体中使用适当的命名空间,示例如下,

     <iterate xmlns:ns1="ReportsDataService" id="MyIterator" expression="//ns1:ReportRowSet/ns1:reportRow" sequential="true">
        <target>
           <sequence>
              <log level="custom">
                 <property name="col" expression="//ns1:column1"/>
              </log>
              <call>
                 <endpoint>
                    <http uri-template="http://endpoint.url"/>
                 </endpoint>
              </call>
           </sequence>
        </target>
     </iterate>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM