wso2 ESB:分割/聚集模式 – 单一响应
这不是一个问题,而是一个答案.我是wso2 ESB的新手,并且希望将测试运行实现拆分/收集EIP作为POC的一部分.
我按照我找到的示例进行了操作,并立即得到了一个返回单个响应的工作配置.然而,要获得所有回复,需要花费相当多的时间才能弄明白.大多数给定的样本似乎产生了相同的意外结果.我希望如果你遇到同样的问题,这些行对你有帮助. 建立 我使用soapUI示例服务(搜索操作)作为服务后端.我发送了一个组合消息,搜索两个项目到代理服务器(参见下面的artefact)迭代中介器拆分消息并将其转发到调用soapUI模型的端点.聚合介体等待所有响应并尝试将其放入一个结果消息中. 问题 虽然拆分器工作正常,但聚合器只返回一个结果元素而不是预期的元素列表.所有日志显示一切正常,几个请求被发送到相应的端点,但仍然只有最终响应中返回的第一个响应. 解 在将代理的日志级别设置为TRACE之后,我意识到聚合器工作正常,只是它创建了一个不符合SOAP的消息.所有聚集的元素都直接添加到肥皂体下面.所以问题是如何在body和result标签之间添加一个根元素.我首先尝试了XSLT,但它也只能读取正文的第一个子元素.最后,我发现了一些深深的暗示暗示使用富集调解员(或者更确切地说是一系列),这就是诀窍. >首先使用Enrich将所有相关项目捕获到属性中 文物 演示请求 <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> 配置 <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> 最后一个问题 如果有人可以提示我一些文档或给我一些工作配置的聚合调解器的correlateOn属性,我真的很感激.
您需要做的是,提及迭代器介体中的任何id(请参阅iterator mediator docs)并在聚合器介体中引用相同的id作为相关ID.而已. –
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |