Passing Test Data into SOAP Web Service best practice

Hello,

I have created a data driven Test Suite with CSV Data, which I need to pass into the SOAP Request I am making.

<soapenv:Envelope xmlns:soapenv=“http://schemas.xmlsoap.org/soap/envelope/”>
<soapenv:Header/>
<soapenv:Body>
<getUserDetail>
<userId>${userId}</userId>
</getUserDetail>
</soapenv:Body>
</soapenv:Envelope>

Following way I am binding the variable value into the SOAP Body and making the request:

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import groovy.text.SimpleTemplateEngine as SimpleTemplateEngine

def request = findTestObject(‘GetUserDetail’)
def soapBody = request.soapBody
def binding = getBinding()
def variables = binding.variables
def templateEngine = new SimpleTemplateEngine()
def template = templateEngine.createTemplate(soapBody)
request.soapBody = template.make(variables).toString()
def response = WS.sendRequest(request)

Is this the best practice in Katalon Studio for calling SOAP Web Service for Data Driven Automation?

Hi there,

Oh my bad because you can only set static value to the variables, not able to retrieve or pass your script to get variable value. If you don’t have any needs to use various data as input of your variables, then it’s OK to use your solution from the beginning

Any update?

Hello Vinh,

I exactly did the same by following the documentation. Those variables I am accessing through the call getBinding().variables. I was wondering if this is the best way to

access those defined variables
generate the SOAP request by using Groovy Template Engine

Regards

To adapt with Data Driven Automation in Katalon Studio, those variables from your test case need to be defined as local variables in the test case. Then setup your test suite followed with this guide.