Store return value of SOAP API into variable


#1

Dear All,

Here is my Return Message in SOAP API:

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=“http://www.w3.org/2001/XMLSchema”>
soap:Body


99079191802324503

119.27.27.69



</soap:Body>
</soap:Envelope>

How can i store value of SessionID in Global Variable and use it for next API?

Thanks


#2

def content = response.getResponseBodyContent()
def textcontent = new XmlParser().parseText(result)
GlobalVariable.SessionID = (textcontent.StartSessionResult.SessionId.text())
println(GlobalVariable.SessionID)

By this code, i can assign value for variable now. But how can i import variable into request of next API?
here is the request:

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=“http://www.w3.org/2001/XMLSchema” xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/”>
soap:Body

Config_RakutenLife_Test


</soap:Body>
</soap:Envelope>

ConfigSetName is the value that i want to input variable


#3

save the value to a global variable and grab it in the second testcase. this will be scoped only to a testsuite so you have to create one
or, at the end of tc1 return it as a value and call tc1 from tc2
or, export it to an external file, that will work across any scenario