Hey guys,
I’m writing this question in order to find a solution on how to utilize a response from a SOAP call for another request.
For example:
I have a soap call that is returning me
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<CheckParticipantResponse xmlns="http://questionmark.com/QMWISe/">
<Status>2
</Status>
</CheckParticipantResponse>
</soap:Body>
</soap:Envelope>
I would like to use request.Status which is 2 in the call after
example = WS.sendRequest(findTestObject('xyz/xyz', [('url') : GlobalVariable.url
, ('username') : "test1" , ('password') : "test2", ('status'):2]))
What is the most efficient way to do this.
Thanks
A sample Test Case:
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.testobject.ResponseObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import groovy.util.slurpersupport.GPathResult
ResponseObject res = WS.sendRequest(findTestObject("soaprequestendpoint"))
String body = res.getResponseText()
WS.comment("body is " + body)
GPathResult parsed = new XmlSlurper().parseText(body)
String status = parsed.Body.CheckParticipantResponse.Status.text().trim()
WS.comment("Status is " + status)
Output in the console:
2021-12-02 09:30:40.920 INFO c.k.k.c.keyword.builtin.CommentKeyword - body is <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<CheckParticipantResponse xmlns="http://questionmark.com/QMWISe/">
<Status>2
</Status>
</CheckParticipantResponse>
</soap:Body>
</soap:Envelope>
...
2021-12-02 09:30:41.060 INFO c.k.k.c.keyword.builtin.CommentKeyword - Status is 2