How to bind random generated string into Request message body variable?

i have below script to generate random string which is tested working fine, and i have an SOAP object which i put ${productId} as variable in the Request message body.

how to parse the “randomString” into ${productId} ?

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static org.assertj.core.api.Assertions.*

import org.apache.commons.lang.RandomStringUtils

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

import groovy.xml.*
import internal.GlobalVariable

GlobalVariable.TestIssueKey = null

String charset = ((‘A’…‘Z’) + (‘0’…‘9’)).join()
Integer length = 9
String randomString = RandomStringUtils.random(length, charset.toCharArray())


//call the object
def drug = findTestObject(‘Object Repository/Web Service Request/WM6/genericProductUpdate’)


//POST DRUG and verification
def response = WS.sendRequestAndVerify(drug)


assert response.getStatusCode() == 200

the object rs file (1.8 KB)

If I am not mistaken, you want to pass a variable into your web service object. Please refer to this:

I think something like this would work, assuming in body message you use ${productId}

def drug = findTestObject(‘Object Repository/Web Service Request/WM6/genericProductUpdate’, ['productId' : randomString]);

Thanks I managed to do it. Earlier the format incorrect so always returned error. Now working.