DataPower

DataPower

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Action Input/Output variables

    Posted Thu April 01, 2021 09:34 AM

    Hello,

    In a gateway script, I need to generate two variables var1.xml and var1.JSON from input. One variable has xml data and another variable has JSON data. In the gateway script I am planning to use session.output.write (var1). Output of this action is dpvar_1

    (1) In second action, I need to validate the var1.JSON with JSON schema. Can I use dpvar_1.JSON as input to this action?

    (2) In the third action I need to validate the var1.xml using XML schema. Can I use dpvar_1.xml as input to this action? Sometime this variable (var1.xml) will be null. At this time the xml validation should not happen. (Planning to use Conditional action).

    Are the output of the action variables like dpvar_1, dpvar_2 etc context variables? Can these variables be accessed as below in the error rule if there is an error?

    var ctx = session.name('input');

    var varaction = ctx.getVar('dpvar_1');

    This does not work.



    #DataPower
    #Support
    #SupportMigration


  • 2.  RE: Action Input/Output variables

    Posted Fri April 30, 2021 04:03 AM

    Hi,

    Here is answers,

    Are the output of the action variables like dpvar_1, dpvar_2 etc context variables? Yes, it should be

    Can these variables be accessed as below in the error rule if there is an error? Yes, you can access it.

    var ctx = session.name('input');

    var varaction = ctx.getVar('dpvar_1');

    Use the following code to create context

    // set variable to the input contextsession.input.setVar('myInputVar',{myInputValue: 4});// get variable from the input contextvarmyInputVar=session.input.getVar('myInputVar');// {myInputValue: 4}// create a context named `myContext` if not existvarctx=session.name('myContext')||session.createContext('myContext');

    Thanks



    #DataPower
    #Support
    #SupportMigration