How to access property mediator outside iterator which is defined inside iterator?

与世无争的帅哥 提交于 2019-12-11 23:19:52

问题


I have treed as below

<iterate xmlns:oag="http://www.openapplications.org/oagis/10" xmlns:fn="http://www.w3.org/2005/xpath-functions" continueParent="true" preservePayload="true" attachPath="//ProcessCredit/DataArea" expression="//ProcessCredit/DataArea/Credit sequential="true">
.....
 <property xmlns:ns="http://org.apache.synapse/xsd"
                        xmlns:oa="http://www.openapplications.org/oagis/10"
                        name="ChargeTransactionKey"
                        expression="concat(get-property('operation','ChargeTransactionKey'),//Extension/ValueText[@typeCode='Charge Transaction Key'],':')"
                        scope="operation"
                        type="STRING"
                        description="ChargeTransactionKey"/>
 ...........

</iterate >
<log level="full">
<property name="requestIdChargeTransactionKey"
                  expression="get-property('operation','ChargeTransactionKey')"/>
     </log>

but value in property "requestIdChargeTransactionKey" is null, it means I'm unable to capture the property which is defined inside iterator.

can anybody help on syntax?


回答1:


The mediation inside iterate works with clones of MessageContext. If you continue parent mediation (set continueParent attribute to true), you work with the initial MessageContext and therefore all the properties you have set with scope 'default' inside iterate are lost

But there is a scope named 'operation' used to retrieve a property in the operation context level and if you set a property with this scope inside iterate, you can get it's value in the parent mediation

Inside iterate :

<property name="ChargeTransactionKey" value="xxx" scope="operation"/>

In parent mediation :

get-property('operation','ChargeTransactionKey')



回答2:


WSO2 Documentation, You can fetch the property in the operation context level from the operation scope.

The properties within iterated/cloned message with the operation scope are preserved in the sequence even if you have configured your API resources to be sent through the fault sequence when faults exist.

get-property('operation', String propertyName)

A given property with the operation scope only exists in a single request and can be accessed by a single resource. The properties in this scope are passed to the error handler when the FORCE_ERROR_ON_SOAP_FAULT property is set to true



来源:https://stackoverflow.com/questions/35201264/how-to-access-property-mediator-outside-iterator-which-is-defined-inside-iterato

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!