Iterator 从WSO2 ESB/EI中聚合的enclosingElementProperty获取元素

Iterator 从WSO2 ESB/EI中聚合的enclosingElementProperty获取元素,iterator,wso2,wso2esb,aggregation,wso2ei,Iterator,Wso2,Wso2esb,Aggregation,Wso2ei,我正在wso2 EI中执行迭代和聚合操作。我想从聚合响应中获取元素值,聚合后未打印后续日志。有人能帮我找到此解决方案吗 代理代码: <proxy name="VBReadFromEmailBody" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse"> <target> <inSequence>

我正在wso2 EI中执行迭代和聚合操作。我想从聚合响应中获取元素值,聚合后未打印后续日志。有人能帮我找到此解决方案吗

代理代码:

<proxy name="VBReadFromEmailBody" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
        <target>
            <inSequence>
            <iterate expression="//jsonArray/jsonElement" id="LDVid" sequential="true">
                            <target>
                                <sequence>
                                    <sequence description="VBEmail_LDVNonQualifiedLead_Sequence" key="VBEmail_LDVNonQualifiedLead_Sequence"/>
                                </sequence>
                            </target>
                        </iterate>
                        <property name="Aggregated_Responses" scope="default">
                            <jsonObject/>
                        </property>
                        <aggregate id="LDVid">
                            <completeCondition>
                                <messageCount max="-1" min="-1"/>
                            </completeCondition>
                            <onComplete enclosingElementProperty="Aggregated_Responses" expression="$body/*[1]" xmlns:ns="http://org.apache.synapse/xsd">
                                <log level="full"/>
                            <loopback/>
                            </onComplete>
                        </aggregate>
                    </case>
                    <default/>
                </switch>
            </inSequence>
            <outSequence>
                <log level="custom">
                <property name="======OUTSEQUENCE=======" value="CALLED"/>
            </log>

                   <log level="full"/>
                <property name="messageType" scope="axis2" type="STRING" value="application/json"/>
                <foreach expression="//jsonValue" id="foreach_id">
                    <sequence>
                        <log level="custom">
                            <property expression="json-eval($.)" name="====each payload===="/>
                        </log>
                        <script language="js"><![CDATA[var log = mc.getServiceLog();        
payload = mc.getPayloadJSON().toString();log.info("Logging payload;;;;" + payload); payloadRemoveSlash = payload.replace("\\", ""); mc.setProperty('payloadRemoveSlash',payloadRemoveSlash);]]></script>
                    </sequence>
                </foreach>
                <!--
                DB Tracing (Response values stored in DB)-->
            </outSequence>
             </target>
    </proxy>
[2020-04-25 14:39:42,741] []  INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:516c93bf-fb2d-46af-8cc8-2b3e56a5e
7ef, Direction: response, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><jsonObject><jso
nValue>"{\"transactionId\":null,\"timestamp\":\"2020-04-25 19:09:41\",\"OpportunityId\":\"0065500000FyUJOAA3\",\"message\":\"Insert/Update success\",\"Lead\":{\"attributes\":{\"typ
e\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AuBvGEAV\"},\"Company\":\"N/A\",\"Email\":\"jaxonstevens18@gmail.com\",\"Lead_Type__c\":\"Internet\",\"LeadSourc
e\":\"LDV i-Motor - Get a Quote\",\"FirstName\":\"Jaxon\",\"Account__c\":\"0015500000k8ow5AAA\",\"LastName\":\"Stevens\",\"Contact__c\":\"0035500000h2R5yAAE\",\"Id\":\"00Q5500000Au
BvGEAV\",\"MobilePhone\":\"+61 423 927 100\"},\"errorCode\":\"200\",\"appraisalId\":null}"</jsonValue><jsonValue>"{\"transactionId\":null,\"timestamp\":\"2020-04-25 19:09:42\",\"Op
portunityId\":\"0065500000FyUJYAA3\",\"message\":\"Insert/Update success\",\"Lead\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AuBvLE
AV\"},\"Company\":\"N/A\",\"Email\":\"steveross01@bigpond.com\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"LDV Facebook - Book a Test Drive\",\"FirstName\":\"Stephen\",\"Accoun
t__c\":\"0015500000k8opxAAA\",\"LastName\":\"Ross\",\"Contact__c\":\"0035500000h2R1wAAE\",\"Id\":\"00Q5500000AuBvLEAV\",\"MobilePhone\":\"+61 414 404 774\"},\"errorCode\":\"200\",\
"appraisalId\":null}"</jsonValue><jsonValue>"{\"transactionId\":null,\"timestamp\":\"2020-04-25 19:09:42\",\"OpportunityId\":\"0065500000FyUJTAA3\",\"message\":\"Insert/Update succ
ess\",\"Lead\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AuBvQEAV\"},\"Company\":\"N/A\",\"Email\":\"dunleavy2010@hotmail.com\",\"Le
ad_Type__c\":\"Internet\",\"LeadSource\":\"LDV i-Motor - Get a Quote\",\"FirstName\":\"Brendan\",\"Account__c\":\"0015500000k8oVhAAI\",\"LastName\":\"Dunleavy\",\"Contact__c\":\"00
35500000h2Ql6AAE\",\"Id\":\"00Q5500000AuBvQEAV\",\"MobilePhone\":\"+61 449 819 834\"},\"errorCode\":\"200\",\"appraisalId\":null}"</jsonValue></jsonObject></soapenv:Body></soapenv:
Envelope>


不要在OnComplete中使用
,请尝试使用
。这可能会解决这个问题。

Hi@Arunan,谢谢你的回答。环回按预期工作。但“聚合的_响应”属性不包含来自Salesforce的响应。如果我在oncomplete内部打印日志,则会出现sf响应(表达式=“$body/*[1]”)。日志:将响应设置为“”。响应将设置为正文,而不是属性“聚合的\u响应”。您可以尝试记录body()并检查是否有响应。如果存在,您可以使用enrich mediator将其充实为属性。嗨@Arunan,我已经将enrich也包括在正文中。在scriptmediator中,我没有得到完整的负载,只得到第一个json元素。如何在脚本中获取完整聚合负载并在负载中执行斜杠删除操作?你能告诉我吗?请分享你正在使用的EI版本Hi Arunan,我的本地服务器是6.3.0,但在生产环境中是EI 6.1.1版本。