Get Response Headers from script
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Get Response Headers from script
Hi, I'm trying to execute soapui tests from my junit tests (junit integration)
How can I get the response headers for assertion?
I can get the raw response property from test step, but is there any way I can use the "messageExchange.responseHeaders" from my junit test?
Thank you
Solved! Go to Solution.
- Labels:
-
Assertions
-
Scripting
-
SOAP
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hope are you running the ReadyAPI project? Do you have the assertion in the project / test step?
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @kasunrama ! Did you manage to solve this?
If not, please provide us with more details!
Sonya Mihaljova
Community and Education Specialist
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello kasunrama,
I have been successful at retrieving header values from a response by using the HarResponse of a service response. I don't know if I understand your question completely, but the following is some groovy script code you can hack from to see if anything could work for you to capture a header value from a response.
def harResponse = context.expand( '${HTTP Request GET authentication-service#HarResponse}' )
log.info ' harResponse "' + harResponse;
def jsonHarResponse = new groovy.json.JsonSlurper().parseText(harResponse);
log.info 'jsonHarResponse=' + jsonHarResponse;
//jsonExpected = 'Bundle';
//assert jsonContent.resourceType == jsonExpected, 'Expected "' + jsonExpected + '" but got "' + jsonContent.dbResult + '"';
def headerResponseList = chooseNewResourceIdFromResponse();
log.info ('Transform Response Headers:');
log.info ('');
subjectToken = '';
headerResponseList.each {
log.info (' ' + it);
if (it.contains('Subject-Token: ')) {
subjectTokenList = it.tokenize(': ');
subjectToken = subjectTokenList[1];
subjectTokenList .each {
log.info (' token ' + it);
};
};
};
log.info ('');
testRunner.testCase.testSteps["Properties"].setPropertyValue( "subjectToken", subjectToken);
Regards,
Todd
