Service Virtualization

  • 1.  Virtualize REST service and insert a record in Database

    Posted Jun 20, 2017 02:00 AM

    Hi, How to virtualize REST service and insert a record into the db table with a message saying successfully inserted or if trying to insert duplicate data it should display message as record exists.. 



  • 2.  Re: Virtualize REST service and insert a record in Database
    Best Answer

    Posted Jun 20, 2017 07:05 PM

    VSM's are extensible so you can add steps to your model based on requirements. You can also change responses at runtime.

     

    - Allow the VS Image Selection Step to execute in the VSM so the service creates a proper lisa_vse_response object. Use an empty VSI with no operations so the VSI responds with the Service Image not found response. Change the Service Image Response (Meta Data tab) to HTTP 200 OK. Change Content-Type to whatever type of content the service needs to use.

     

    - Add the INSERT SQL after the VS Image Selection step and before the Responder step. The SQL step is located in Other Transactions --> SQL Database Execution (JDBC) Database. If the parameters used in the insert SQL are in the request, you can reference them using {{request_<argumentNameParsedByDPH>}} notation.  Change "<argumentName...>" to the correct value that is parsed on your incoming request.

    - Add a Store Step Response filter to the INSERT SQL step. Name it fl_databaseResponse.

    When the Responder Step executes, the service will substitute the value of fl_databaseResponse into the response that goes on the wire. If the response is XML, replace the above JSON. If not XML or JSON, just add the property {{fl_databaseResponse}} by itself.



  • 3.  Re: Virtualize REST service and insert a record in Database

    Posted Jul 18, 2017 02:08 AM

    Thank u Joel.

    But I used output log message step after adding JDBC step to display msg.