header
header
Main Menu
Home
Eviware Store
Downloads
Products
News
Forum
Eviware Blog
Search
FAQs
Customer Area
Support
Documentation
Tutorials
CookBook
Downloads
Forum
Login Form
Welcome, Guest. Please login or register.
November 22, 2008, 02:44:19 pm
Username: Password:
Login with username, password and session length

Forgot your password?
 
handling session in response
Welcome, Guest. Please login or register.
November 22, 2008, 02:44:19 pm
Home Help Search Login Register
News: The Forums are up! Welcome to eviware.

+  Eviware Forum
|-+  soapUI
| |-+  soapUI
| | |-+  handling session in response
« previous next »
Pages: [1] Print
Author Topic: handling session in response  (Read 732 times)
ind
Newbie
*
Posts: 6


« on: July 26, 2007, 10:17:31 am »

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(<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

Logged
ind
Newbie
*
Posts: 6


« Reply #1 on: July 26, 2007, 10:21:03 am »

hi all,

here is my SOAP response after i hit my login

<userlogin>
<action>success</action>
<sessionid>123asdf</sessionid>
</userlogin>

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

thanks
ind
Logged
nreimertz
Administrator
Full Member
*****
Posts: 205


« Reply #2 on: July 26, 2007, 10:28:27 am »

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
 

 
Logged
nreimertz
Administrator
Full Member
*****
Posts: 205


« Reply #3 on: July 26, 2007, 10:39:32 am »

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...
Logged
ind
Newbie
*
Posts: 6


« Reply #4 on: July 26, 2007, 12:14:24 pm »

thanks,

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

request
----------
 <web:GetUKLocationByPostCode>
         <!--Optional:-->
         <web:PostCode>33</web:PostCode>
      </web:GetUKLocationByPostCode>

response
------------
<GetUKLocationByPostCodeResponse xmlns="http://www.webserviceX.NET">
         <GetUKLocationByPostCodeResult><![CDATA[<NewDataSet>
  <Table>
    <Town>Banavie</Town>
    <County>Highland</County>
    <PostCode>PH33</PostCode>
  </Table>

how to get country or postcode in response or web:PostCode in request
in groovy

thanks
ind

Logged
nreimertz
Administrator
Full Member
*****
Posts: 205


« Reply #5 on: July 26, 2007, 02:08:07 pm »

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.


Code:
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:

Code:
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"))
Logged
ind
Newbie
*
Posts: 6


« Reply #6 on: July 27, 2007, 06:40:18 am »

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


Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
header header
header
header