cancel
Showing results for 
Search instead for 
Did you mean: 

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 response.so that i can use those values for next coming request.

thanks
ind
6 REPLIES 6
Occasional Contributor

Re: handling session in response

hi all,

here is my SOAP response after i hit my login


success
123asdf


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

thanks
ind

Re: handling session in response

Hi!

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='http://example.example.com;
//ns1:loginResponse/ns1:loginReturn

Example Target XPath:
declare namespace ns1='http://example.example.com';
//ns1:nextcall/ns1:sessionId
Product Guy for Ready! API, SoapUI and all things API

Re: handling session in response

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

Re: handling session in response

thanks,

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

request
----------

       
        33
     


response
------------

        <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

Re: handling session in response

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 com.eviware.soapui.support.GroovyUtils( 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

Re: handling session in response

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" )
log.info(a)

the response i got is :

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

the value is null.

thanks!!!
ind
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors