Forum Discussion
Cizo89
11 years agoFrequent Contributor
Hi Aniket,
what are exactly your requirements?
You need that sessionToken as a TestCase Custom Property in your TestCases or do you need this sessionToken passed directly to your webservices?
If you want to stored this sessionToken as a property in your TestCases, try this:
If you need it as header in your REST webservices, try this:
I hope it will help you
Regards,
Marek
what are exactly your requirements?
You need that sessionToken as a TestCase Custom Property in your TestCases or do you need this sessionToken passed directly to your webservices?
If you want to stored this sessionToken as a property in your TestCases, try this:
String sessionToken = context.expand('${YOUR_AUTH_SERVICE#ResponseAsXml#//Response[1]/SessionToken[1]}')
for (testSuite in testRunner.testCase.testSuite.project.getTestSuiteList()){
for (testCase in testSuite.getTestCaseList()){
testCase.setPropertyValue("SessionToken", sessionToken)
}
}
If you need it as header in your REST webservices, try this:
import com.eviware.soapui.support.types.StringToStringMap
StringToStringMap header = new StringToStringMap()
header.put("x-token", context.expand('${YOUR_AUTH_SERVICE#ResponseAsXml#//Response[1]/SessionToken[1]}'))
for (testSuite in testRunner.testCase.testSuite.project.getTestSuiteList()){
for (testCase in testSuite.getTestCaseList()){
for (testStep in testCase.getTestStepList()){
if (testStep.getConfig().getType() == "restrequest"){
testStep.testRequest.setRequestHeaders(header)
}
}
}
}
I hope it will help you
Regards,
Marek