title: Soapui - How to maintain session from login post request to get request
body: <p>Im using soapui(5.2.1) for webservice testing , not able to hit the rest api-Get request followed by 
  post request (authentication).</p>
  
  <p>Below are the scritps that i have</p>
  
  <p>1 Login(Post request) - Login</p>
  
  <p>2 SetCookie - Groovyscript</p>
  
  <p>3.GetBasic(Get request) - To get json output data</p>
  
  <p>4.RunAll(Run all the teststep (Post request,SetCookie,Get request) )- Groovyscript</p>
  
  <p>First request is working fine , tried to hit get request but throws "this requires http authentication".
  I searched few blogs and written setcookie groovy script and below are the code.</p>
  
  <pre><code>def header = testRunner.testCase.getTestStepByName("Login").httpRequest.response.responseHeaders["Set-Cookie"]
  
  header=header.toString()
  
  start=header.indexOf("JSESSIONID=")
  
  end=header.indexOf("; Path=")
  
  testCaseProperty= header.substring(start,end)
  
  testRunner.testCase.testSuite.setPropertyValue( "JSESSIONID", testCaseProperty )
  
  testRunner.testCase.testSuite.project.setPropertyValue( "JSESSIONID", testCaseProperty )
  
  log.info "jsession id - "+testCaseProperty
  </code></pre>
  
  <p>After that at  GetBasic test step i set the header ${#TestSuite#JSESSIONID}.Then in RunAll 
  script i have mentioned the step1,2,3 to run.</p>
  
  <p>1.Login executed succesfully (username,password specified)
  2.Set cookie executed succesfully
  3.GetSystemdata(Get request) fails (throws "This requires http authentication")</p>
  
  <p>But manually when i select the test case(check maintain session) and execute(Step1,2,3) it works fine</p>
  
  <p>Please find the attached snap for the reference , can any one helpme on this please.</p>
  
  <p>Note(Setcookie script set the cookie but it is not used by GetBasic get request)</p>