# Store return value of SOAP API into variable

**URL:** <https://forum.katalon.com/t/store-return-value-of-soap-api-into-variable/28836>\
**Category:** API Testing\
**Tags:** api-testing, katalon-studio\
**Created:** [June 28, 2019, 6:33am UTC](https://forum.katalon.com/t/store-return-value-of-soap-api-into-variable/28836 "2019-06-28T06:33:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dangnh007](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@dangnh007](https://forum.katalon.com/u/dangnh007)\
**Post date:** [June 28, 2019, 6:33am UTC](https://forum.katalon.com/t/store-return-value-of-soap-api-into-variable/28836/1 "2019-06-28T06:33:17Z")

</div>

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/](http://schemas.xmlsoap.org/soap/envelope/)” xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)” xmlns:xsd=“[XML Schema](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

---

<div class="post-metadata">

**Author:** ![dangnh007](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@dangnh007](https://forum.katalon.com/u/dangnh007)\
**Post date:** [June 28, 2019, 8:33am UTC](https://forum.katalon.com/t/store-return-value-of-soap-api-into-variable/28836/2 "2019-06-28T08:33:03Z")

</div>

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](http://www.w3.org/2001/XMLSchema-instance)” xmlns:xsd=“[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)” xmlns:soap=“[http://schemas.xmlsoap.org/soap/envelope/](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

---

<div class="post-metadata">

**Author:** ![Ibus](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@Ibus](https://forum.katalon.com/u/Ibus)\
**Post date:** [June 28, 2019, 9:33am UTC](https://forum.katalon.com/t/store-return-value-of-soap-api-into-variable/28836/3 "2019-06-28T09:33:50Z")

</div>

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

---

<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:43am UTC](https://forum.katalon.com/t/store-return-value-of-soap-api-into-variable/28836/4 "2022-08-08T07:43:36Z")

</div>

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


