This is not a question , but rather the answer . I am completely new to wso2 ESB and wanted to do a test run implementing EIP split / build as part of POC. I followed the examples I found and immediately got a working configurator that returned a single response. However, to get answers to all the answers, it took quite a while to figure it out. Most of these samples seemed to produce the same unexpected result. I hope that if you encounter the same problem, these lines will be useful to you.
Customization
I used the soapUI sample service (search operation) as a service. I sent a combined message to search for two items on a proxy server (see artifact below). the iterative mediator splits the message and forwards it to the endpoint that calls the soapUI layout. the aggregated mediator expects all responses and tries to put it in one result message.
Problem
Although the splitter worked correctly, the aggregator returned only one element of the result , and not a list of elements as expected. All the logs showed that everything was in order, several requests were sent to the corresponding endpoints, but in the final answer, only the first answer was returned.
Decision
After setting the proxy log level for TRACE, I realized that the aggregator worked just fine, only he created a message that does not match SOAP. All aggregated items were added directly under the soap . So the question was how to add one root element between body and result tags. At first I tried XSLT, but it could only read the first child of the body as well. Finally, I found a deep-rooted allusion to using an enriching intermediary (or rather a series), and this did the trick. The following list explains the part of the configuration (code shown below) that is not found in most examples.
- Use Enrich first to capture all matching elements in a property
- Forget the current message - rewrite the full envelope with the body containing only the new root payload element
- Attach the elements stored in the property to the new payload root.
- If necessary, grab the soap header in the property and add it to the new msg (not in the config below)
Artifacts
Demo request
<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>
Config
<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>
Finally the question
If someone can hint me some documentation or give me some working configuration for the correlateOn attribute of the aggregated broker, I would really appreciate it.