0

I am trying to virtualize an API using ServiceV. What I want to do is, have a request to pull data from JDBC (oracle db in my case), send a request to the virtual service, when the request hits the virtual service, the service looks for a unique identifier (Primary key) and based on that primary key, it fetches the right row from the database.

What I have done so far is: Managed to set up an oracleDB and connected it into our ReadyAPI project and I’ve managed to get data from the database into our request (filling in the various headers like ID, status, party ID etc) and we can return a response that also picks data out of a different table.

The next step for us is customising the SQL query on the response level to select the specific response based on the primary key from the request table.

The problem I’ve found with this is I'm not too sure where the SQL query customisation would occur. At the moment I have an SQL query run on the request level in SOAP UI and then a separate request happens in the DataSources part of the virt end to fill the response form with data. This virt end SQL query is the one I want to be able to dynamically change.

Would you have any idea of how I can achieve this?

Kris Rice
  • 3,300
  • 15
  • 33
Jhanz
  • 127
  • 3
  • 3
  • 12

1 Answers1

0

From my understanding (and correct me if I'm wrong) what you are asking is for a way to customise the virtual responses from ServiceV to match the data returned in the SoapUI DataSource.

Under this assumption, I would recommend keeping all DB calls within the SoapUI portion of your code and write each line of the database that you want the mocking service to return, to either GlobalProperties or ProjectProperties.

Then, in ServiceV, configure the responses substituting hardcoded values with something akin to ..."id" : "${#Project#Identifier}".... This will grab the current DB details being inputted within SoapUI and use them as response values in the virt service to maintain consistency of assertions.

Or you can utilise the Dispatch Style Script and input your query into Groovy

Cheers - D