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.  Gatewayscript to read binary context variable

    Posted Mon March 09, 2020 11:32 PM
    Hello,

    In binary transform action - we are sending an request to an external server using dp:url-open with response set as responsecode-binary, its then saved in context variable and xsl:message terminate is invoked if responsecode is not 200.

    I'm in error processing using gatewayscript. Now, is there a way in gatewayscript to convert this binary nodeset to string? I've tried using toString() method, but its not working as expected.

    Output is " [object NodeList]"

    What I'm doing wrong? Please help to handle this case.

    var rawResponse = ctx.getVariable('Response').toString("hex");
    console.debug(rawResponse);


    ------------------------------
    Thanks,
    Kumar
    ------------------------------


  • 2.  RE: Gatewayscript to read binary context variable

    Posted Tue March 10, 2020 05:07 AM

    Hi,

    binary nodes are stored inside a NodeList as your output shows.
    Use "ctx.getVariable('Response').item(0).toBuffer()" to get buffer containing the binary data.
    Then you can do anything you like with the buffer as  .toString("hex")



    ------------------------------
    Hermann Stamm-Wilbrandt
    Compiler Level 3 support & Fixpack team lead
    IBM DataPower Gateways (⬚ᵈᵃᵗᵃ / ⣏⠆⡮⡆⢹⠁⡮⡆⡯⠂⢎⠆⡧⡇⣟⡃⡿⡃)
    ------------------------------