# 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..?

**URL:** <https://forum.katalon.com/t/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/8071>\
**Category:** Miscellaneous\
**Tags:** api-testing, katalon-studio\
**Created:** [October 21, 2017, 2:54pm UTC](https://forum.katalon.com/t/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/8071 "2017-10-21T14:54:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qaddaffi\_Sulaiman](https://avatars.discourse-cdn.com/v4/letter/q/da6949/32.png) [@Qaddaffi\_Sulaiman](https://forum.katalon.com/u/Qaddaffi_Sulaiman)\
**Post date:** [October 21, 2017, 2:54pm UTC](https://forum.katalon.com/t/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/8071/1 "2017-10-21T14:54:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Qaddaffi\_Sulaiman](https://avatars.discourse-cdn.com/v4/letter/q/da6949/32.png) [@Qaddaffi\_Sulaiman](https://forum.katalon.com/u/Qaddaffi_Sulaiman)\
**Post date:** [May 22, 2017, 7:53am UTC](https://forum.katalon.com/t/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/8071/2 "2017-05-22T07:53:57Z")

</div>

Hi [Vinh Nguyen](http://forum.katalon.com/author/vinhnguyenkms-technology-com/),

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.

---

<div class="post-metadata">

**Author:** ![Zarashima](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/zarashima/32/928_2.png) [@Zarashima](https://forum.katalon.com/u/Zarashima)\
**Post date:** [May 10, 2017, 2:05pm UTC](https://forum.katalon.com/t/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/8071/3 "2017-05-10T14:05:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Zarashima](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/zarashima/32/928_2.png) [@Zarashima](https://forum.katalon.com/u/Zarashima)\
**Post date:** [May 10, 2017, 1:57pm UTC](https://forum.katalon.com/t/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/8071/4 "2017-05-10T13:57:35Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![Qaddaffi\_Sulaiman](https://avatars.discourse-cdn.com/v4/letter/q/da6949/32.png) [@Qaddaffi\_Sulaiman](https://forum.katalon.com/u/Qaddaffi_Sulaiman)\
**Post date:** [May 10, 2017, 8:28am UTC](https://forum.katalon.com/t/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/8071/5 "2017-05-10T08:28:44Z")

</div>

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](http://prntscr.com/f6417b)

---

<div class="post-metadata">

**Author:** ![Zarashima](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/zarashima/32/928_2.png) [@Zarashima](https://forum.katalon.com/u/Zarashima)\
**Post date:** [May 10, 2017, 1:34am UTC](https://forum.katalon.com/t/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/8071/6 "2017-05-10T01:34:48Z")

</div>

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](http://prnt.sc/f615sw) . You can see a full list of APIs for Web Service object in this [page](http://api-docs.katalon.com/studio/v4.5.0/api/com.kms.katalon.core/com/kms/katalon/core/testobject/RequestObject.html)

Please let me know if you have any other questions

---

<div class="post-metadata">

**Author:** ![albert.vu](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/albert.vu/32/20595_2.png) [@albert.vu](https://forum.katalon.com/u/albert.vu)\
**Post date:** [August 8, 2022, 7:25am UTC](https://forum.katalon.com/t/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/8071/7 "2022-08-08T07:25:04Z")

</div>

Archived on August 8, 2022, 7:25am UTC


