Ask a Question

handling session in response

Occasional Contributor

handling session in response

Hi all,

I have a SOAP request for Login and i am getting proper response for the user credentials. Now in the SOAP response the session id()node is passed to it.

I need to get the value of the session id from the that i can use those values for next coming request.

Occasional Contributor

hi all,

here is my SOAP response after i hit my login


how to get the value of session id node ...



You can do this in a Transfer Step.

Create a transfer that transfers from your login step  (step login, property response ) to your next step (step nextstep, property request) and use  XPath expressions to to move it:

Example Source XPath:
declare namespace ns1=';

Example Target XPath:
declare namespace ns1='';
Product Guy for Ready! API, SoapUI and all things API

One more thing,

if you are using the soapUI Pro trial, this is even easier. To the right of the Property Drop Down, there is a button that lets you choose which element you want (in your case sessionID) and it will generate the XPath for you.

This is Pro only though...
Product Guy for Ready! API, SoapUI and all things API
Occasional Contributor


in case if i want to get a node value in request/ do i do that




        <NewDataSet><br />&nbsp; <Table><br />&nbsp; &nbsp; <Town>Banavie</Town><br />&nbsp; &nbsp; <County>Highland</County><br />&nbsp; &nbsp; <PostCode>PH33</PostCode><br />&nbsp; </Table><br /><br />how to get country or postcode in response or web:PostCode in request<br />in groovy<br /><br />thanks<br />ind

Ok, this is my personal way of doing it.

Since I'm not that fond of the XML parsing in Groovy (read: because I'm lazy),  I would make a Properties Step containing properties for these:
Request PostCode
Response PostCode

I would then move them into the properties step using a Property Transfer like above (only now into the Properties Step) and the accessing the Properties Step from Groovy.

def step = testRunner.testCase.getTestStepByName( "Properties" )
step.getPropertyValue( "Request PostCode " )
step.getPropertyValue( "Response PostCode " )

In Pro it is simpler to use Grovy and I would use the GroovyUtils like this:

def groovyUtils = new context )

def respHolder  = groovyUtils.getXmlHolder( "GetUKLocationByPostCode#Response" )
def reqHolder  = groovyUtils.getXmlHolder( "GetUKLocationByPostCode#Request" )

reqpHolder.getNodeValue( "//web:GetUKLocationByPostCode/web:PostCode"))
resppHolder.getNodeValue( "//web:GetUKLocationByPostCodeResult/Table/PostCode"))
Product Guy for Ready! API, SoapUI and all things API
Occasional Contributor

thanks for the prompt response.
i have tried with your code. but null value only it passes.

i have used this groovy code:
def step = testRunner.testCase.getTestStepByName( "GetUKLocationByPostCode - Request 1" )
def a = step.getPropertyValue( "//web:GetUKLocationByPostCode/web:PostCode" )

the response i got is :

Fri Jul 27 11:07:11 IST 2007:INFO:null

the value is null.

Showing results for 
Search instead for 
Did you mean: