Service Virtualization

 View Only
  • 1.  Error while using scriptable data protocol

    Posted Mar 05, 2018 02:06 PM



    I am writing a simple scriptable data protocol in which i need to modify the incoming request.


    String theBody = lisa_vse_request.toString();


    after this few line of code to interpret the request.


    But i am getting error at processing this single line.


    below is the error

    Did not get a valid Request object so we ignore processing this transaction.
    at bsh.ParseException.getErrorLineNumber(
    at bsh.BshScriptEngine.evalSource(
    at bsh.BshScriptEngine.eval(
    at javax.script.AbstractScriptEngine.eval(Unknown Source)
    at com.itko.lisa.test.ScriptExecHandler.executeScript(
    at com.itko.lisa.test.ScriptExecHandler.executeScript(
    at com.itko.lisa.test.ScriptExecHandler.executeScript(
    at com.itko.lisa.test.ScriptExecHandler.executeScript(
    at com.itko.lisa.test.TestExec.executeScript(
    at com.itko.lisa.vse.stateful.protocol.scriptable.ScriptableDataProtocolHandler.updateRequest(
    at com.itko.lisa.vse.stateful.common.DataProtocolStandardControlFilter.subPostFilter(
    at com.itko.lisa.test.FilterBaseImpl.subFilter(
    at com.itko.lisa.test.FilterBaseImpl.postFilter(
    at com.itko.lisa.test.TestNode.doFilters(
    at com.itko.lisa.test.TestNode.doPostFilters(
    at com.itko.lisa.test.TestNode.executeNode(
    at com.itko.lisa.test.TestCase.execute(
    at com.itko.lisa.test.TestCase.execute(
    at com.itko.lisa.test.TestCase.executeNextNode(
    at com.itko.lisa.editor.WalkThruPanel.prepAndExecNode(
    at com.itko.lisa.editor.WalkThruPanel.access$900(
    at com.itko.lisa.editor.WalkThruPanel$10.doCallback(
    at com.itko.util.swing.panels.ProcessingDialog$
    at Source)


    But when i am changing data protocol to Web services(soap) i am getting the response.


    can someone please tell me what additional thing i need to do to have a valid Request object.

  • 2.  Re: Error while using scriptable data protocol

    Posted Mar 05, 2018 03:06 PM

    Is it possible to post the entire script so we can look over it? 

    It is possible that an error elsewhere in the script throws and the interpreter gets confused as to the line number.

    If you want the body of the request, try using:  String theBody = lisa_vse_request.getBodyAsString(); 

    Arguments and MetaData can be accessed if DPHs prior to the Scriptable have populated them.

    The VS_<yourServiceName>.log also has a display showing the Inbound Request so you can check to ensure that a malformed request is not being processed.  The log entries look something like this:

    yyyy-MM-dd HH:mm:ss,794Z (10:29)[xxxx [VS_xxxxx_Run]/1] INFO - Inbound Request {"id":0,"operation":"POST /some/uri","arguments":{"arg_key_1":"arg_value_1","arg_key_2":"arg_value_2"}, "metadata":{<metaData key/value pairs here}, and so on }

  • 3.  Re: Error while using scriptable data protocol

    Posted Mar 05, 2018 03:10 PM

    Hi Joel,


    I am getting error for this line only I removed my remaining code and tried with above line only and got the same error. 

  • 4.  Re: Error while using scriptable data protocol

    Posted Mar 05, 2018 03:18 PM

    Ok, that would be a good test to verify the error.  I am interested in why the Request object is null.  

    Can you provide information as to what the incoming request looks like (i.e., transport HTTP, type of data such as REST, XML, binary, etc., if any DPHs are in the chain before this one, and a dump of the Inbound Request)?  Please remove any identifiable information if the input has customer specific data.

  • 5.  Re: Error while using scriptable data protocol

    Posted Mar 06, 2018 05:23 AM

    This is how the request looks like

    end point url: http://localhost:8030/itkoExamples/EJB3AccountControlBean


    <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="" xmlns:xsd="" xmlns:xsi=""><soapenv:Body><depositMoney xmlns=""><accountId xmlns="">2295050569862</accountId><amount xmlns="">50.00</amount><desc xmlns="">ATM Deposit</desc></depositMoney></soapenv:Body></soapenv:Envelope>


    there no DPH before this one

  • 6.  Re: Error while using scriptable data protocol
    Best Answer

    Posted Mar 06, 2018 10:18 AM
      |   view attached

    I cannot explain why the exception is thrown, but the following is working in my local environment.


    Since the example is Soap XML, I would suggest using the Soap DPH as the first DPH in the chain and then follow on with a Scriptable. 

    The function of the Soap DPH is to parse the XML and set the operation. There is no real reason to use a Scriptable for parsing XML manually.

    The attached project ZIP file shows the differences. 

    Assume we have an input request containing XML as follows:


    Sending the request to the example_withoutSoapDPH.vsm running in ITR mode.  Stop after the Listen Step and look at the Events tab.

    The Scriptable DPH in the VSM places log messages showing the request and the body. 


    Running the example_withSoapDPH.vsm in ITR mode.

    In this VSM, the SOAP DPH fires first and is followed by a Scriptable that simply displays what the SOAP DPH created.

    Stop the previous service and run this service in ITR mode.

    Stop after the Listen Step and review the Events tab.

    The highlighted displays below show that the operation and arguments were parsed from the XML by the Soap DPH.

    The Scriptable in both VSMs accesses the lisa_vse_request object and retrieves different things from them. 


    zip   21 KB 1 version

  • 7.  Re: Error while using scriptable data protocol

    Posted Mar 06, 2018 03:22 PM

    What if I have my XML request in escape format witch &Ltd; and &gt; how to

    process such request can you suggest any way ?


    On Tue, 6 Mar 2018 at 8:48 PM, Joel_Nesmith <

  • 8.  Re: Error while using scriptable data protocol

    Posted Mar 07, 2018 09:30 AM
      |   view attached

    In this scenario, you could consider two DPHs. DPHs fire in the order they occur in the Listen Step Filters. So, our first DPH converts the data into a format that another DPH can accept and process.


    DPH 1 could be a Scriptable DPH. In this DPH decode the XML string and set it back into the Request body:

    import com.itko.util.XMLUtils;

    String decodedXML = XMLUtils.decodeString( lisa_vse_request.getBodyAsString() );

    lisa_vse_request.setBody( decodedXML  );


    DPH2 is the SOAP DPH. This DPH parses the decoded XML into an arg list.

    Example of encoding and decoding an XML is attached as a Test Case.


    NOTE: DPHs do not operate on the original incoming transaction. This preserves the original request in case Live Invocation is used. This is a point of confusion for many in the Community. We see the question asked quite a bit about modifying the original request prior to sending it to the Live Invocation endpoint. DevTest's philosophy is that the Live Invocation should use the payload passed by the consumer. Modifying the original payload prior to sending 'live' is not an accurate representation of what the consumer application is expecting when the call is made. 


    zip   1 KB 1 version