Service Virtualization

 View Only
  • 1.  unable to add argument and apply in response using scriptable data protocol

    Posted Sep 14, 2022 05:07 PM
    request file:
    GET /test/portal HTTP/1.1
    connection: keep-alive
    content-type: application/json

    {
    "name":"30206151900",
    }
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    beanshell script in scriptable data protocol:
    %beanshell%
    import com.itko.util.ParameterList;
    import java.io.*;
    import java.util.*;
    import java.lang.String;
    import com.itko.util.ParameterList;
    ParameterList args = lisa_vse_request.getArguments();
    newval2 = "30206151900";
    newVal3 = "302061520";
    addr = "new zealand";
    if(args.getParameterValue("name").equals(newval2)) {
    addr = "wellington street, australia,";
    }
    if(args.getParameterValue("name").equals(newVal3)) {
    addr = "new york street, us";
    }
    args.setParameterValue("status", addr);
    lisa_vse_request.setArguments(args);

    the argument "status" is getting added in vsi file but when i add "name": "{{=request_status;/*302061519*/}}" in reponse body it is unable to detect the data/value based on above script


  • 2.  RE: unable to add argument and apply in response using scriptable data protocol

    Broadcom Employee
    Posted Sep 15, 2022 03:35 AM
    Hi Nikhil,

    If the script correctly adds status to the request argument then the issue
    is not with the script. From what you say I believe the script works
    correctly because your transactions inside your VSI have the status
    argument.

    Is the "status" argument marked as a magic string inside the VSI? Because
    if not then the property request_status will not exist.
    During testing, have you verified in the inspection view that the request
    transaction coming into the VS also has the status argument present?
    Because if not then your script worked during the creation of the VSI but
    is maybe missing in the VSM (or has an other issue there).

    Cheers,

    Danny Saro

    Client Services Consultant

    Broadcom Software


    -------------------------------------------------

    --
    This electronic communication and the information and any files transmitted
    with it, or attached to it, are confidential and are intended solely for
    the use of the individual or entity to whom it is addressed and may contain
    information that is confidential, legally privileged, protected by privacy
    laws, or otherwise restricted from disclosure to anyone else. If you are
    not the intended recipient or the person responsible for delivering the
    e-mail to the intended recipient, you are hereby notified that any use,
    copying, distributing, dissemination, forwarding, printing, or copying of
    this e-mail is strictly prohibited. If you received this e-mail in error,
    please return the e-mail to the sender, delete it from your computer, and
    destroy any printed copy of it.




  • 3.  RE: unable to add argument and apply in response using scriptable data protocol

    Posted Sep 15, 2022 05:04 AM
    Hi Danny,

    yes i have marked it as magic string in vsi file, also in inspect view i see the variable request_name getting detected request_status is being added from script as new argument that is not shown in inspect view.


  • 4.  RE: unable to add argument and apply in response using scriptable data protocol

    Broadcom Employee
    Posted Sep 15, 2022 07:31 AM
    Hi,

    If you don't see "status" added as an argument to the incoming request in
    Inspection View that would mean that the script has not ran correctly
    within the VSM of the deployed VS. Try to have a look at the VSE log to see
    if there are any beanshell error that might indicate why the script failed.

    PS. the requirements that you implement in the script can be easily
    implemented in the VSI using specific transactions without the need of any
    coding

    Cheers,

    Danny Saro

    Client Services Consultant

    Broadcom Software


    -------------------------------------------------

    --
    This electronic communication and the information and any files transmitted
    with it, or attached to it, are confidential and are intended solely for
    the use of the individual or entity to whom it is addressed and may contain
    information that is confidential, legally privileged, protected by privacy
    laws, or otherwise restricted from disclosure to anyone else. If you are
    not the intended recipient or the person responsible for delivering the
    e-mail to the intended recipient, you are hereby notified that any use,
    copying, distributing, dissemination, forwarding, printing, or copying of
    this e-mail is strictly prohibited. If you received this e-mail in error,
    please return the e-mail to the sender, delete it from your computer, and
    destroy any printed copy of it.




  • 5.  RE: unable to add argument and apply in response using scriptable data protocol

    Posted Sep 29, 2022 12:15 PM
    Hi Nikhil,

    In the VSI, you can use the comparison operator to define the response combinations based on your requirement. This will eliminate any code/script dependency in your virtual service.

    Thanks

    ------------------------------
    Regards,
    Vaibhav Jain
    Capgemini
    ------------------------------