Wso2 esb foreach

时间:2017-09-26 13:27:49

标签: wso2 wso2esb

我使用WSO2 ESB v6.1.1并在使用json作为有效负载的foreach / iterator介体中遇到一些问题。在使用foreach循环之后,它应该返回所有修改过的元素,但是观察到只返回了最后一个元素。

我发送的请求是

[{  
      "id":101,
      "FirstName":"Kaith",
      "lastName":"Williams",
      "email":"kwilliams@yahoo.com",
      "mobile":"123-287-9665",
      "dateOfBirth":"null"
   }

  {  
      "id":102,
      "FirstName":"Rahul",
      "lastName":"Williams",
      "email":"Rwilliams@yahoo.com",
      "mobile":"123-333-9665",
      "dateOfBirth":"null"
   }


{  
      "id":103,
      "FirstName":"abishek",
      "lastName":"Williams",
      "email":"Awilliams@yahoo.com",
      "mobile":"123-287-4565",
      "dateOfBirth":"null"
   }

]

预期响应

[{  
      "id":101,
      "Name":"Kaith",
      "lastName":"Williams",
      "email":"kwilliams@yahoo.com",
      "mobile":"123-287-9665",
      "dateOfBirth":"null"
   }

  {  
      "id":102,
      "Name":"Rahul",
      "lastName":"Williams",
      "email":"Rwilliams@yahoo.com",
      "mobile":"123-333-9665",
      "dateOfBirth":"null"
   }


{  
      "id":103,
      "Name":"abishek",
      "lastName":"Williams",
      "email":"Awilliams@yahoo.com",
      "mobile":"123-287-4565",
      "dateOfBirth":"null"
   }

]

我得到的回应是

    [ 
     {  
          "id":103,
          "Name":"abishek",
          "lastName":"Williams",
          "email":"Awilliams@yahoo.com",
          "mobile":"123-287-4565",
          "dateOfBirth":"null"
      }
    ]

我的主要Xml文件是

<?xml version="1.0" encoding="UTF-8"?>
<api context="/sam1" name="testsample" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET">
        <inSequence>
            <send>
                <endpoint>
                    <address uri="http://customers.pcfdev.kpit.com/customers"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
            <foreach expression="//jsonArray/jsonElement">
                <sequence>

                    <payloadFactory description="" media-type="json">
                        <format>


   [{  
      "id":$1,
      "Name":"$2",
      "lastName":"$3",
      "email":"$4",
      "mobile":"$5",
      "dateOfBirth":"$6"
   }
]
</format>
                        <args>
                            <arg evaluator="json" expression="$.id"/>
                            <arg evaluator="json" expression="$.firstName"/>
                            <arg evaluator="json" expression="$.lastName"/>
                            <arg evaluator="json" expression="$.email"/>
                            <arg evaluator="json" expression="$.mobile"/>
                            <arg evaluator="json" expression="$.dateOfBirth"/>
                        </args>
                    </payloadFactory>
                    <log level="full"/>
                </sequence>
            </foreach>
            <send/>
        </outSequence>
        <faultSequence/>
    </resource>
</api>

使用log in out-sequence我在控制台中获得了正确的输出,但在浏览器中没有 同样的问题也发生在iterator上。

0 个答案:

没有答案