rrsqrd
11 years agoNew Contributor
setting header value in a rest request
Hi,
I am a c/c++ developer with a few Java courses under my belt and I am new to
webservices/rest/soapUI/groovy/testing etc so please bear with me.
Note that I am using the open source soapUI.
I need to retrieve a value from a rest 'response header field' and then use it in a subsequent rest 'request header field'.
Scenario: loginRequest returns a value in it's response header that I need to extract and use in subsequent requests such as logOut.
I have managed to extract the value from the login response header and am storing it in a property at the test case level
def headerValueFromResponse = testRunner.testCase.testSteps["LoginRequest"].testRequest.response.responseHeaders["NewHeader"][0]
testRunner.testCase.setPropertyValue("NewHeaderProperty", headerValueFromResponse )
I have also manually added the newHeader field to the subsequent request, in this case logOut.
(value is temporarily hard coded)
I can retrieve the property value using an expansion
def expandHeaderProperty = context.expand('${#TestCase#NewHeaderProperty}')
Now I need to be able to use this value and set the respective header field in the logOut request header.
But I haven't had much luck finding anything that 'smells' of setting a header field with code.
Are there methods available that will allow me do this using open source soapUI?
I watched a smartbear video and saw that event handlers were used to do what I am trying to do.
It used sbutmitListener.afterSubmit and sbumitListener.beforeSubmit to dig into getRequest and getResponse methods.
Event handlers don't seem to be available in open source soapUI.
I am wondering if I will need to use soapUI Pro.
thanks in advance.
r2
I am a c/c++ developer with a few Java courses under my belt and I am new to
webservices/rest/soapUI/groovy/testing etc so please bear with me.
Note that I am using the open source soapUI.
I need to retrieve a value from a rest 'response header field' and then use it in a subsequent rest 'request header field'.
Scenario: loginRequest returns a value in it's response header that I need to extract and use in subsequent requests such as logOut.
I have managed to extract the value from the login response header and am storing it in a property at the test case level
def headerValueFromResponse = testRunner.testCase.testSteps["LoginRequest"].testRequest.response.responseHeaders["NewHeader"][0]
testRunner.testCase.setPropertyValue("NewHeaderProperty", headerValueFromResponse )
I have also manually added the newHeader field to the subsequent request, in this case logOut.
(value is temporarily hard coded)
I can retrieve the property value using an expansion
def expandHeaderProperty = context.expand('${#TestCase#NewHeaderProperty}')
Now I need to be able to use this value and set the respective header field in the logOut request header.
But I haven't had much luck finding anything that 'smells' of setting a header field with code.
Are there methods available that will allow me do this using open source soapUI?
I watched a smartbear video and saw that event handlers were used to do what I am trying to do.
It used sbutmitListener.afterSubmit and sbumitListener.beforeSubmit to dig into getRequest and getResponse methods.
Event handlers don't seem to be available in open source soapUI.
I am wondering if I will need to use soapUI Pro.
thanks in advance.
r2