Parasoft virtualize groovy scripting example to read the json element

I am using multiple responses in JSON responder where the response is mapped one to one. Now I am in need of dynamic value in response like timestamp, value based on the random number and etc. It is should be based on input values. I tried varies example to get input string values in Groovy scripts without much success
Ex:
public Object handleOutput(context) {
return context.get(SOAPUtil.XML_REQUEST);
}
def correlateOperation(context) {
return context.get(CorrelationScriptingHookConstants.MESSAGE_STR) ;
}

Any working example will be great help.

Comments

  • williammccuskerwilliammccusker Posts: 434 ✭✭

    Hi,
    To make sure I understand you want to script a value based on something in the incoming request and then send that back out in the response? Would it make sense to chain you script, or timestamp maybe a data generator tool, to the incoming request and then data bank the output from the script? The data banked variable could then be referenced in the response.

  • balakumar1982balakumar1982 Posts: 2

    I have three groups of requests. Each group will have different responses. one group type will have current date and few dynamic values. Other will have past date date and few dynamic values. Last one will have future date and another set of dynamic values.

  • williammccuskerwilliammccusker Posts: 434 ✭✭

    Hi,
    I think that chaining tools to the incoming request to script or generate values which you then put into a data bank will probably be the easier way to do what you want.

    I attached a simple example of using the data generator to create a date/timestamp and use it in the response message.

Sign In or Register to comment.