Synapse/WSO2: Modifying a message in proxy service with iterate mediator -
here's problem i'm trying solve:
- receive message
- enrich message calling service obtain information (the other service happens wso2 data service, using mock proxy works same); see here info on enrich pattern
- send message on way
the input message looks this:
<purchaseorder xmlns="http://example.com/samples"> <header> <vendordata> <vendornumber>123456</vendornumber> </vendordata> </header> <body> <lineitem> <itemnumber>111222333</itemnumber> </lineitem> <lineitem> <itemnumber>333224444</itemnumber> </lineitem> <lineitem> <itemnumber>123456789</itemnumber> </lineitem> </body> </purchaseorder>
... , output message should this:
<purchaseorder xmlns="http://example.com/samples"> <header> <vendordata> <vendornumber>123456</vendornumber> </vendordata> <vendorterms> <discount> <description>15% net 10</description> <discountdays>10</discountdays> </discount> <days>30</days> <termsid>001</termsid> </vendorterms> </header> <body> <lineitem> <itemnumber>111222333</itemnumber> <sku>abc123pdq789</sku> <cost>9.99</cost> <description>widget, small</description> </lineitem> <lineitem> <itemnumber>333224444</itemnumber> <sku>0000143214</sku> <cost>99.99</cost> <description>big ticket item</description> </lineitem> <lineitem> <itemnumber>123456789</itemnumber> <sku>01121245245</sku> <cost>15.99</cost> <description>widget bundle, large (10)</description> </lineitem> </body> </purchaseorder>
... additional information obtained calling other services.
below proxy service definition trying, , enrich mediator outside of iterate mediator works expected. it's enrich mediator inside iterate mediator not working expected. under impression had use aggregate mediator tie together.
i've looked through wso2 , synapse examples such problem, , assume using iterate mediator send mediator call other services, not same i'm doing here.
proxy service definition:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="dss_mockpoc" transports="https,http" statistics="enable" trace="enable" startonload="true"> <target> <insequence> <property xmlns:ex="http://example.com/samples" name="vendornumber" expression="//ex:purchaseorder/ex:header/ex:vendordata/ex:vendornumber" scope="default" type="string"/> <callout serviceurl="local:///services/mock_termslookup/" action="urn:mediate"> <source type="envelope"/> <target key="termsresponse"/> </callout> <enrich> <source clone="true" xpath="synapse:get-property('termsresponse')"/> <target xmlns:ex="http://example.com/samples" action="sibling" xpath="//ex:purchaseorder/ex:header/ex:vendordata"/> </enrich> <iterate xmlns:ex="http://example.com/samples" continueparent="true" id="lineitemiterator" preservepayload="true" attachpath="//ex:purchaseorder/ex:body" expression="//ex:purchaseorder/ex:body/ex:lineitem" sequential="true"> <target> <sequence> <property name="itemlookuprequest" expression="$body" scope="default" type="om"/> <callout serviceurl="local:///services/mock_itemlookup/" action="urn:mediate"> <source key="itemlookuprequest"/> <target key="itemlookupresponse"/> </callout> <enrich> <source type="property" clone="true" property="itemlookupresponse"/> <target xpath="//ex:lineitem"/> </enrich> </sequence> </target> </iterate> <aggregate id="lineitemiterator"> <correlateon xmlns:ex="http://example.com/samples" expression="//ex:purchaseorder/ex:header"/> <completecondition> <messagecount min="-1" max="-1"/> </completecondition> <oncomplete xmlns:ex="http://example.com/samples" expression="//ex:purchaseorder/ex:body/ex:lineitem"> <log level="full"/> </oncomplete> </aggregate> <property name="response" value="true" scope="default" type="string"/> <header name="to" action="remove"/> <send/> </insequence> </target> <description></description> </proxy>
finally, when calling service. through logging, can see iterate mediator sending , receiving correct information; results not propagated return message.
<purchaseorder xmlns="http://example.com/samples"> <header> <vendordata> <vendornumber>123456</vendornumber> </vendordata> <vendorterms> <discount> <description>15 % net 10</description> <discountdays>10</discountdays> </discount> <days>30</days> <termsid>001</termsid> </vendorterms> </header> <body> <lineitem> <itemnumber>111222333</itemnumber> </lineitem> <lineitem> <itemnumber>333224444</itemnumber> </lineitem> <lineitem> <itemnumber>123456789</itemnumber> </lineitem> </body> </purchaseorder>
Comments
Post a Comment