wso2 ESB:分割/聚集模式 - 单一响应

dre*_*mer 6 esb aggregate wso2 mediator

不是一个问题,而是一个答案.我是wso2 ESB的新手,并希望在POC中实现拆分/收集EIP的测试运行.我按照我找到的示例,立即得到了一个返回单个响应的工作配置.然而,要获得所有回复,需要花费相当多的时间才能弄明白.大多数给定的样本似乎产生了相同的意外结果.我希望如果遇到同样的问题,这些行对你有帮助.

建立

我使用soapUI示例服务(搜索操作)作为服务后端.我发送了一个组合消息,搜索两个项目到代理服务器(参见下面的artefact)迭代中介器拆分消息并将其转发到调用soapUI模型的端点.该总调解人等待所有响应,并试图把它变成一个结果消息.

问题

虽然拆分器工作正常,但聚合器返回一个结果元素而不是预期的元素列表.所有日志显示一切正常,几个请求被发送到相应的端点,但仍然只有最终响应返回的最终响应.

在将代理的日志级别设置为TRACE之后,我意识到聚合器工作得很好,只是它创建了一个不符合SOAP的消息.所有聚集的元素直接添加到肥皂体下面.所以问题是如何在body和result标签之间添加一个根元素.我首先尝试了XSLT,但它也只能读取正文的第一个子元素.最后,我发现了一些深埋提示使用充实调解员(或相当的一系列),并且没有的伎俩.以下列表说明了大多数示例中未找到的配置部分(如下所示).

  1. 首先使用Enrich将所有相关项目捕获到属性中
  2. 忘记当前消息 - 用仅包含新有效负载根元素的主体重写完整的包络
  3. 将存储在属性中的元素附加到新的有效负载根目录.
  4. 如果需要,将soap标头捕获到属性中并将其附加到新的msg中(不在下面的配置中)

文物

演示请求

<body>
   <sam:multisearch xmlns:sam="http://www.example.org/sample/">
      <sam:search>
         <sessionid>123</sessionid>
         <searchstring>Item 1</searchstring>
      </sam:search>
      <sam:search>
         <sessionid>123</sessionid>
         <searchstring>Item 2</searchstring>
      </sam:search>
   </sam:multisearch>
</body>
Run Code Online (Sandbox Code Playgroud)

配置

<proxy xmlns="http://ws.apache.org/ns/synapse" name="test.multisearch" transports="https,http" statistics="enable" trace="enable" startOnLoad="true">
   <target>
      <inSequence>
         <iterate xmlns:sam="http://www.example.org/sample/" expression="//sam:multisearch/sam:search">
            <target>
               <sequence>
                  <send>
                     <endpoint key="soapUI_Mockup"/>
                  </send>
               </sequence>
            </target>
         </iterate>
      </inSequence>
      <outSequence>
         <aggregate>
            <completeCondition>
               <messageCount min="-1" max="-1"/>
            </completeCondition>
            <onComplete xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sam="http://www.example.org/sample/" expression="//sam:searchResponse">
               <enrich>
                  <source clone="true" xpath="$body//item"/>
                  <target type="property" property="ResultItems"/>
               </enrich>
               <log level="custom">
                  <property name="ResultItems" expression="get-property('ResultItems')"/>
               </log>
               <enrich>
                  <source type="inline" clone="true">
                     <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">                        
                        <soapenv:Header/>                        
                        <soapenv:Body>                           
                           <sam:GenericDataResponse/>                        
                        </soapenv:Body>                     
                     </soapenv:Envelope>
                  </source>
                  <target type="envelope"/>
               </enrich>
               <enrich>
                  <source type="property" clone="true" property="ResultItems"/>
                  <target action="child" xpath="//sam:GenericDataResponse"/>
               </enrich>
               <send/>
            </onComplete>
         </aggregate>
      </outSequence>
   </target>
   <description></description>
</proxy>
Run Code Online (Sandbox Code Playgroud)

最后一个问题

如果有人可以提示我一些文档或给我一些工作配置的聚合调解器的correlateOn属性,我真的很感激.

Sub*_*nga 2

您需要做的是,在迭代器中介器中提及任何 id(请参阅迭代器中介器文档),并在聚合器中介器中引用相同的 id 作为相关 id。就是这样。\xe2\x80\x93

\n