2013-07-12 77 views
0

我创建了具有请求作为代理:如何合并WSO2 ESB中的响应?

<body> 
<p:GetPersonDataOperation xmlns:p="http://tempuri.org"> 
    <!--1 or more occurrences--> 
    <xs:ID xmlns:xs="http://tempuri.org">1</xs:ID> 
    <xs:ID xmlns:xs="http://tempuri.org">2</xs:ID> 
</p:GetPersonDataOperation> 
</body> 

现在inSequence中我已经使用迭代器为:

<sequence xmlns="http://ws.apache.org/ns/synapse" name="GetPersonDataOperationSeq"> 
    <iterate xmlns:xs="http://tempuri.org" xmlns:ns="http://org.apache.synapse/xsd" xmlns:p="http://tempuri.org" preservePayload="true" attachPath="//p:GetPersonData" expression="//p:GetPersonData/xs:ID" id="IteratorForPersonData"> 
     <target> 
     <sequence> 
      <property name="ID" expression="//xs:ID" scope="default" type="String"/> 
      <filter xpath="count(//xs:ID)>0"> 
       <then> 
        <log level="custom"> 
        <property name="sequence" value="with id"/> 
        </log> 
        <payloadFactory> 
        <format> 
         <p:GetPersonDataOperation>$1</p:GetPersonDataOperation> 
        </format> 
        <args> 
         <arg expression="get-property('ID')"/> 
        </args> 
        </payloadFactory> 
        <send> 
        <endpoint key="GetPersonDataEP"/> 
        </send> 
       </then> 
       <else/> 
      </filter> 
     </sequence> 
     </target> 
    </iterate> 
</sequence> 

时,我打我的代理与上述要求,我能够得到输出但不适用于两个ID,但ID = 2。我想要得到两个响应,即ID = 1和ID = 2。我知道这可以使用XSLT Mediator完成但我没有任何有关XSLT Transformation的知识。我怎样才能创建一个自定义响应通过合并ID = 1和2使用xslt中介的答复。我可以使用Aggregate Mediator解决这个问题吗? 在这方面需要帮助很严重。提前感谢

+0

我有这样的问题。我解决它,所以http://stackoverflow.com/questions/17443232/as-in-the-iterate-to-change-the-message-and-send-it-fully-wso2esb –

回答

0

您可以在out序列中使用Aggregate mediator合并来自iterate mediator的响应。也参考Aggregator EIP

你可以在out序列中使用类似下面的东西。

<outSequence> 
     <aggregate> 
      <completeCondition> 
       <messageCount min="-1" max="-1" /> 
      </completeCondition> 
      <onComplete xmlns:p="http://tempuri.org" expression="//p:GetPersonDataResponse"> 
       <log level="full" /> 
       <send /> 
      </onComplete> 
     </aggregate> 
</outSequence> 

This blog post有一个类似的例子。

+0

但上述表达给我看超时表达式 – Roy