WSO2 总计更改有效载荷

WSO2 change payload in aggregate

我目前正在尝试从序列模板计算聚合元素中的有效负载。我的问题是此序列返回的有效负载是由聚合生成的,而不是使用有效负载工厂构建的有效负载。这是一个示例

<clone id="TEST" sequential="true">
  <target>
    <sequence>
       <call-template key="do-soemthing"/>
    </sequence>
  </target>
  <target>
    <sequence>
       <call-template key="do-something-else"/>
    </sequence>
  </target>
</clone>
<aggregate id="TEST">
 <completeCondition>
   <messageCount max="-1" min="-1"/>
 </completeCondition>
 <onComplete expression="//status">
    <filter xpath="count(//status[text() = 'NOK']) = 0">
      <then>
        <payloadFactory media-type="xml">
          <format>
            <myPayload>
              <status>OK</status>
              <action>foo</action>
            </myPayload>
          </format>
          <args/>
        </payloadFactory>
      </then>
      <else>
        <payloadFactory media-type="xml">
          <format>
            <myPayload>
              <status>NOK</status>
              <action>bar</action>
            </myPayload>
          </format>
          <args/>
        </payloadFactory>
      </else>
    </filter>
  </onComplete>
</aggregate> 

调用此序列时我期望的是取回一个元素,但我却得到了(聚合)。 我该如何解决这个问题?

谢谢

如果要在克隆后执行中介,则必须在克隆中介上设置属性 continueParent="true"。

但这在您的情况下还不够,因为生成到克隆目标中的消息在克隆中介之后丢失:您必须按顺序移动聚合中介并在每个克隆目标中调用此序列。

这是一个由代理服务(您可以简单地使用您的互联网浏览器执行:http://localhost:8280/services/TestSOF)和用于聚合模拟响应的序列组成的示例

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="TestSOF"
       transports="http"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <inSequence>
         <property name="messageType" value="application/xml" scope="axis2"/>
         <clone continueParent="true">
            <target>
               <sequence>
                  <payloadFactory media-type="xml">
                     <format>
                        <resp1 xmlns="">
                           <status>OK</status>
                        </resp1>
                     </format>
                     <args/>
                  </payloadFactory>
                  <header name="To" action="remove"/>
                  <property name="RESPONSE" value="true"/>
                  <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
                  <sequence key="TestSOFAgg"/>
               </sequence>
            </target>
            <target>
               <sequence>
                  <payloadFactory media-type="xml">
                     <format>
                        <resp2 xmlns="">
                           <status>OK</status>
                        </resp2>
                     </format>
                     <args/>
                  </payloadFactory>
                  <header name="To" action="remove"/>
                  <property name="RESPONSE" value="true"/>
                  <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
                  <sequence key="TestSOFAgg"/>
               </sequence>
            </target>
         </clone>
         <log level="full">
            <property name="DEBUG" value="after clone"/>
         </log>
      </inSequence>
   </target>
</proxy>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="TestSOFAgg">
    <aggregate>
     <completeCondition>
       <messageCount max="-1" min="-1"/>
     </completeCondition>
     <onComplete expression="//status">
        <log level="full"><property name="DEBUG" value="inside onComplete"/></log>
        <filter xpath="count(//status[text() = 'NOK']) = 0">
          <then>
            <payloadFactory media-type="xml">
              <format>
                <myPayload>
                  <status>OK</status>
                  <action>foo</action>
                </myPayload>
              </format>
              <args/>
            </payloadFactory>
          </then>
          <else>
            <payloadFactory media-type="xml">
              <format>
                <myPayload>
                  <status>NOK</status>
                  <action>bar</action>
                </myPayload>
              </format>
              <args/>
            </payloadFactory>
          </else>
        </filter>
        <respond/>
      </onComplete>
    </aggregate> 
</sequence>

查看 "after clone" 记录的消息:soap Body 是空的(如果您使用浏览器对其进行测试,或者您将收到使用 SoapUI 发送的 soap 消息),您的聚合不能在这里工作

查看 "inside onComplete" 记录的消息:您可以看到 soap 体内的所有状态元素

用其他可以接受的内容修改其中一个模拟响应,然后重试:响应更改,有效 ;-)