Service Virtualization

  • 1.  JDBC CA LISA Service Virtualization, how to implement following scenario's in LISA 9.5.1

    Posted Apr 25, 2017 04:50 AM

    I have a request.

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <soapenv:Body>
          <Request
             <Name>BruceWayne</Name>
          </Request>
       </soapenv:Body>
    </soapenv:Envelope>

     

    The response for this is :-

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <soapenv:Body>
          <Response>
             <Superhero>Batman</Superhero>
          </Response>
       </soapenv:Body>
    </soapenv:Envelope>

     

     

    Now I have a database in which I have following two columns : -

    Name                            Superhero

    BruceWayne                 Batman

     

    How can I implement this query in CA LISA 9.5.1 : - select superhero from Movies where Name='BruceWayne'; ??


    How can I pass the the  value which is in request into the SQL query, so that the value I am sending in the response can be read from it ??



  • 2.  Re: JDBC CA LISA Service Virtualization, how to implement following scenario's in LISA 9.5.1

    Posted Apr 25, 2017 05:05 AM

    Hello Vineet,

    Simple solution is to modify corresponding VSM. Add Database step in your VSM just before response selection step. Enter required connection details along with SQL query [select superhero from Movies where Name='{{requestPara}}']. As you would expect dynamic Name to pass in SQL query so you'll have to capture that from the incoming request message. 

     

    Use testExec.getStateValue("Argument Name as shown in VSI") to capture incoming request Argument in any variable say 'requestPara'. It can be done by adding Java Script step or scripted assertion in Listener step.

     

    Now, next step would be to add filter to the database step to store step response which anyway is really simple; thanks to CA's intelligent minds to provide simplified solution.

     

    Alright, so you have captured expected data from database successfully. Next step is to update VSI file to send captured dynamic data in response message. Simply open VSI and pass variable/ property name wherein you have captured SQL result. You can update VSI node like <Superhero>{{dbSuperHero}}</Superhero> and you are all set to run dynamic service.

     

    Hope, it helps !

     

    Thanks,

    Kumar

    Please ignore typos.



  • 3.  Re: JDBC CA LISA Service Virtualization, how to implement following scenario's in LISA 9.5.1

    Posted Apr 25, 2017 05:21 AM

    Thanks Gaurav,

    I am able to connect to db, fetch result, store result in filter and then pass in response.

    But I didn't quite get how to store request attribute in filter. In scripted assertion I am getting option to return true/false. How can I store value in variable using that ?

    Thanks and Regards,
    Vineet Singh



  • 4.  Re: JDBC CA LISA Service Virtualization, how to implement following scenario's in LISA 9.5.1
    Best Answer

    Posted Apr 25, 2017 05:37 AM

    Hello Vineet,

    You just have to use below mentioned line of code in scripted assertion followed by return true;

     

    String reqName=testExec.getStateValue("request_ArgumentName");

    return true;

     

    Sometimes, it doesn't work. In that case use below line of code.

    testExec.setStateValue("VARIABLE_TO_STORE_VALUE",lisa_vse_request.getArguments().getParameterValue("ARGUMENT_NAME"));
    Make sure you don't append "request_" in above line of code.

     

    Thanks,

    Kumar