Search code examples
wso2wso2-esbwso2-api-managerwso2-integration-studio

How to pass a value from inSequence to outSequence in WSO2 ESB?


Problem Description:

I'm currently working on a project involving WSO2 ESB, and I'm facing challenges in passing a value from the inSequence to the outSequence.

In my proxy service configuration, I have defined an inSequence where I extract a property called "Action" using the <property> mediator. This "Action" property holds a specific action identifier that determines the subsequent processing logic. Now, I need to access this "Action" property in the outSequence to make decisions and execute different processing steps based on its value.

I've attempted to retrieve the "Action" property in the outSequence using the <property> mediator with the same expression (get-property('Action')), but it doesn't seem to work as intended. Despite setting the scope to "axis2" in both sequences, the value doesn't get passed from the inSequence to the outSequence.

I'm seeking guidance on the correct approach to passing this value from the inSequence to the outSequence in WSO2 ESB. Any insights, suggestions, or code examples would be greatly appreciated.

I tried retrieving the value of the "Action" property from the inSequence and passing it to the outSequence in WSO2 ESB. Specifically, I used the <property> mediator with the expression get-property('Action') in both the inSequence and outSequence of my proxy service configuration.

What I Expected: I expected that by setting the scope of the property mediator to "axis2" in both sequences, the value of the "Action" property extracted in the inSequence would be accessible in the outSequence.

What Actually Resulted: However, despite setting the scope correctly, the value of the "Action" property was not passed from the inSequence to the outSequence as anticipated. When I logged the value of the "Action" property in the outSequence, it returned null, indicating that the value was not successfully transferred.


Solution

  • By default, the Out Sequence deals with the response flow. Therefore, if a property is not available in the response flow, you will be unable to access that property in the Out Sequence. However, if you need to pass a property from the In Sequence to the Out Sequence, you can save the specific property with the scope="default" as shown below in Insequnce:

    <property name="Action" value="SampleAction" scope="default"/>
    

    Then, you can refer to the specific property from the Out Sequence as shown below:

    <property name="Action" expression="$ctx:Action"/>