wso2 - 分散-聚集(克隆+聚合)不起作用

标签 wso2 esb mediator enterprise-integration wso2-esb

我正在尝试使用克隆调用两个端点并收集它们的信息以通过聚合发送,我必须将其与分散收集中介器一起使用。每个端点返回一个 json 字符串。但我一直遇到“期望 SOAP Envelope 的实现作为父级”错误。我的最后一次尝试如下。 我应该在 onComplete 表达式中使用什么来完成这项工作?

<resource methods="GET" uri-template="/allInfo">
        <inSequence>
            <log description="Get All Restaurants Info" level="custom" separator=",">
                <property name="message" value="&quot;All information of restaurants&quot;"/>
            </log>
            <clone description="All Info" id="ScatterGatherProxy">
                <target>
                    <endpoint key="RestaurantLocalsEP"/>
                </target>
                <target>
                    <endpoint key="RestaurantNamesEP"/>
                </target>
            </clone>
        </inSequence>
        <outSequence>
            <aggregate id="ScatterGatherProxy">
                <completeCondition>
                    <messageCount max="-1" min="-1"/>
                </completeCondition>
                <onComplete expression="fn:concat('//*')">
                    <send/>
                </onComplete>
            </aggregate>
        </outSequence>
        <faultSequence/>
    </resource>

最佳答案

聚合中介器包含最新版本 (6.5.0) 中的原生 JSON 支持(即将发布) 此外,还可以通过 WUM 更新为 EI 6.1.1 和 6.4.0 提供 JSON 支持。

您可以使用以下示例配置

<api xmlns="http://ws.apache.org/ns/synapse" name="aggregate"
context="/testAgg">    <resource methods="POST GET">
       <inSequence>
          <log level="custom" separator=",">
             <property name="message" value="&quot;All information of restaurants&quot;"/>
          </log>
          <clone id="ScatterGatherProxy">
             <target>
                <endpoint name="Cape">
                   <address uri="http://www.mocky.io/v2/5befbf782f000067007a0be4" format="get"/>
                </endpoint>
             </target>
             <target>
                <endpoint name="KSC">
                   <address uri="http://www.mocky.io/v2/5befbfd22f00009a007a0be5" format="get"/>
                </endpoint>
             </target>
          </clone>
       </inSequence>
       <outSequence>
          <aggregate id="ScatterGatherProxy">
             <completeCondition>
                <messageCount min="-1" max="-1"/>
             </completeCondition>
             <onComplete expression="json-eval($)">
                <send/>
             </onComplete>
          </aggregate>
       </outSequence>    </resource> </api>

您可以在 https://lahirumadushankablog.wordpress.com/2018/11/17/aggregating-json-payloads-in-wso2-ei/ 中阅读更多信息

关于wso2 - 分散-聚集(克隆+聚合)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55742954/

相关文章:

WSO2 API 管理器和 XACML 授权

wso2 - ESB 4.9.0 和 4.8.1 之间的不同行为

java - JBoss ESB : Using HTTPRouter with a secure endpoint and no keystore

c# - 为什么要为 Mediator 提供 INotification/IRequest 标记接口(interface)?

mediator - MediatR 管道优先级

c# - 当我在测试中设置 IMediator Mock 时返回 null

java - securitypolicy 策略不是 <wsp :Policy> element

ssl - WSO2 ESB : View (ssl) WSDL endpoint carbon console

registry - 从 wso2 注册表获取已部署的服务端点 url

java - 使用 ServiceMix 与 Tomcat/WAR 模型的优缺点是什么?