How to pass test data into soap web service request…? Is it possible to control the properties of soap request programmatically through a script rather than hard coding it..?

I would like to know if it is possible to control the properties of a soap request through a script…? What I mean is, I do not want to hard code the properties of a soap request and I would like to read the values from a file and pass it to the properties or write a function to randomize the values for the properties.

For example, if I have a soap request with two properties, User Name and Password, I would like to pass different values to these properties, each time I call this web service request in a test case.

An example of how to do that would be much appreciated.

Hi Vinh Nguyen,

If it is possible, could you please provide a tutorial on how to test web services using Katalon, perhaps for a simple webservice with steps as to how to pass values dynamically and also how to parse the response data…? A tutorial on this would be highly helpful to clear the the doubts/questions.

1 Like

If you want to use username and password in the web service object, you should pass it to HTTP Header (getHttpHeaderProperties().add()) of that web service object

Ah sorry, you need to have the following import: import com.kms.katalon.core.testobject.TestObjectProperty.

The error message already indicates root cause: unable to resolve class TestObjectProperty

Hi Vinh,

I tried the way you have explained, but I got the following error while running test case,

Test Cases/API_Test FAILED because (of) org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
file:/C:/Users/qaddaffi.sulaiman/Katalon%20Studio/AutomationTrial/Scripts/API_Test/Script1494360124193.groovy: 29: unable to resolve class TestObjectProperty
@ line 29, column 33.
request.getRestParameters().add(new TestObjectProperty(“username”, ConditionType.EQUALS, username))
^

file:/C:/Users/qaddaffi.sulaiman/Katalon%20Studio/AutomationTrial/Scripts/API_Test/Script1494360124193.groovy: 30: unable to resolve class TestObjectProperty
@ line 30, column 33.
request.getRestParameters().add(new TestObjectProperty(“password”, ConditionType.EQUALS, password))
^

2 errors

**********************

The screenshot of the code is at http://prntscr.com/f6417b

Hi there,

Here is my example for REST object:

import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import internal.GlobalVariable as GlobalVariable
import com.kms.katalon.core.testobject.ConditionType as ConditionType
import com.kms.katalon.core.testobject.RequestObject as RequestObject
import com.kms.katalon.core.testobject.TestObjectProperty as TestObjectProperty
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WebAPI
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint

def postId = 1

'Add REST parameter using local variable from Variables tab'
RequestObject request = findTestObject('REST_CommentDetails')
request.getRestParameters().add(new TestObjectProperty('postId', ConditionType.EQUALS, postId))

'Send a REST request and returns its response'
def response = WS.sendRequest(request)

'Verify if comment\'s email after sending request is correct or not'
WS.verifyElementPropertyValue(response, '[0].email', 'Eliseo@gardner.biz')

SOAP request should be the same as they have the same supported APIs: http://prnt.sc/f615sw . You can see a full list of APIs for Web Service object in this page

Please let me know if you have any other questions

Hi @Allex Is it possible to add Soap endpoint the same was as adding paassword?