Forum Discussion

werther78's avatar
New Contributor
6 years ago

Parametize test data from JDBC into request

Hi, I am new to SoapUI, I am able to connect to my database for now. I want to know how can I use the data from the query and input that into the request parameter so that it gives a response using groovy script. My query will give tracking numbers and I want the soapui to input these tracking numbers and give the appropriate response.




2 Replies

  • In SoapUI open source, after JDBC connection, response will be shown in xml format.

    Please see below image, wher I am doing a sample JDBC connection


    From this response I retrieve Email value with this groovy script. And set this Email value as a Properties in TestSuite. So that I can use this property in any TestCase. [${#TestSuite#Properties}]



    Like Email You can retreve Tracking Number from response. I think It will help you. 


  • luluberlu's avatar
    Occasional Contributor


    i got solution for you.

    example of groovy script which recover and test one database field value : 

    before you have : testcase property with expected values, and a JDBC Step which give you database answer :

    <ResultSet fetchSize="0">
    <Row rowNumber="1">





    def reponse = context.expand( '${JDBCTestStep#ResponseAsXml#//*:Results/ResultSet/Row}' )
    def egal = true
    if (reponse != "") {
    // " answer recover : " + reponse 
    // Test field in database 
    def Slurp = new XmlSlurper().parseText(reponse)
    def FieldDB = Slurp."databasename.datafieldname"
    // " FieldDB : " + FieldDB
    def FieldExpected = testRunner.testCase.getPropertyValue("FieldValueExpected")
    if (FieldDB == FieldExpected ) { " the field  " + FieldDB + " is correct in database."}
    else { egal = false; " the field " + FieldDB + " is not correct in database."}
    else { egal = false; " request sent is empty !"}
    assert egal