Service Virtualization

  • 1.  Scriptable Data Protocol error

    Posted Jul 25, 2018 04:14 PM

    I am trying to retrieve a 16 digit card number from one of the incoming argument then create and assign the 16 digit cardnumber to a new argument for matching in VSI.  But i am getting error while trying to create the service using the below code. Any suggestion is appreciated.

     

    %beanshell%

    import com.itko.util.ParameterList;
    import com.itko.lisa.vse.stateful.model.Request;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;

    // Arguments, Attributes, and Metadata are all ParameterList

    ParameterList args = lisa_vse_request.getArguments();
    String INPUT = args.get("systemContext_correlationId");
    String REGEX = "\\d{16}+";
    int iStart, iEnd;
    String CardNumber;

    Pattern p = Pattern.compile(REGEX);

    // get a matcher object
    Matcher m = p.matcher(INPUT);

    while(m.find()) {
    iStart = m.start(); // Set the start position
    iEnd = m.end(); // Set the end position
    CardNumber = INPUT.substring(iStart,iEnd);
    break; // Exit from the while loop after first occurance of the given regex pattern
    }

    args.addParameter(new Parameter("CardNumber", "CardNumber", CardNumber));

    lisa_vse_request.setArguments(args);



  • 2.  Re: Scriptable Data Protocol error

    Broadcom Employee
    Posted Jul 25, 2018 04:21 PM

    A couple of things:

     

    1. Try using String INPUT = args.get("request_systemContext_correlationId"); - I assume the argument name in the VSI shows as systemContext_correlationId

     

    2. Surround your logic in a try catch block & log any exception to understand what could be going wrong.

     



  • 3.  Re: Scriptable Data Protocol error

    Posted Jul 25, 2018 04:33 PM

    I added the "request_" in front the argument name.

     

    The below is the error message i am getting after moving to the next window from scriptable DPH window.

     

    Caused by: javax.script.ScriptException: bsh.TargetError: Sourced file: inline evaluation of: `` import com.itko.util.ParameterList; import com.itko.lisa.vse.stateful.model . . . '' : Typed variable declaration : Method Invocation p.matcher : at Line: 19 : in file: inline evaluation of: `` import com.itko.util.ParameterList; import com.itko.lisa.vse.stateful.model . . . '' : p .matcher ( INPUT )



  • 4.  Re: Scriptable Data Protocol error
    Best Answer

    Posted Jul 26, 2018 09:56 AM

    Figured out that i missed to import the Parameter package. It worked fine after adding the below line at the top my code.

     

    import com.itko.util.Parameter;