Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How add an extension tool that respond requests?

angrymouse
angrymouse Posts: 10
edited April 2018 in Virtualize

Hi, is possible to me add a totally custom response, e.g pass the request to an extension script and let him to respond with a Json?
I'm very confuse about how do this, i try to add a script in the message responder -> response (tab) but on this i only can manipulate context on script created in that way.

I want to receive the input and return the response on the script, and i'm very confused about it, in documentation i can find how i make the script but i can't find where and how i create it.

Thanks if someone can help me

Best Answers

Answers

  • OmarR
    OmarR Posts: 235 admin
    edited May 2018

    Good morning,

    Yes, it is certainly possible to script a custom response. However, what is it that you're trying to accomplish with scripting that you can't with the built-in tools? Perhaps we can propose a better solution :)

    Below is simple scripted responder that returns some JSON:

    Some additional references:

    Language Specific Tips
    Creating a Custom Script/Extension Tool
    Scripting Values Based on Incoming Requests

  • angrymouse
    angrymouse Posts: 10
    edited April 2018

    Thanks for the answer.
    We are trying to customize complex scenarios, atm we are trying to do a POC that can respond with mocks relatives to the input.

    This mocks we want to save in database in diferent tables to choose according to request data. If you have a sugestion for this case i'll be happy xD.

  • angrymouse
    angrymouse Posts: 10
    edited April 2018

    But about your example, doing how you did, i can only access the context object.
    In this state we can't access the request data in the script, how we want.

  • angrymouse
    angrymouse Posts: 10

    Hi Thomas, thank you so much for the answer.
    What i put in "column name" and "Generated Data Source" when i use text databank?

    context.getValue("Generated Data Source", "extracted column name")

  • benken_parasoft
    benken_parasoft Posts: 1,306 ✭✭✭

    In case this helps, see Accessing Data Sources from Scripts