My new website on Artificial Intelligence and Machine Learning

Read the response from a database in SOAPUI

This one requires a bit more work as we need to set up and close a database connection which we can use in our scripts. This is best done in the MockService start script as follows

	import groovy.sql.Sql

	//def mockService=mockRunner.mockService 

	def sql=Sql.newInstance("HostName","username","password","databaseDriver");
	def row=sql.firstRow("select * from table") "=================="+row.get("column1");
	context .responseMessage = row.get("column2");
	if(context.dbConnection!=null){ "Closing the connection";

Aim of Script: Here response is whatever we are getting data from DB. If we want to specifically want specify any condition based on request we can add like where condition with request element value.
   ** Connecting data base and selecting first row. From that row, based on column name we can specially get the value and set to the context.

1. Created mock service for database example. Find the URL details for Service

soap ui mock service for soapui database example

2. This is the response for the request

soap ui mock response for soapui database example

3. Now time to execute the request. Find the request execution

soap ui database service execution


Groovy log:Whatever loggers we are using in script, it will display in Groovy log window.

Groovy log for soapui

soapUI log: soapUI log for process.

soapui log for process

http log: Here headers details and message details will display.

header details in soapui logs

Error log: while running application, if we may face any problems we can verify errors in error log.

Errors in soapui logs

Memory log: memory details

Memory details for soap ui example

Jetty log: whenever will start the mock service, we can identify event in jetty log.