How to retrieve a value from the request header?
Hi All,
I am New to Groovy Scripting, I need to get the value of Host from the header (highlighted in bold), I tried the below code but it did not work. Could someone help me in fixing below code.
Code:
----------
def getHost = mockRequest.getRequestHeaders().get("Host")
if( getHost.contains("wbmgwy1-sit1.metest.local"))
{
// return the name of the response you want to dispatch
return "L-Env-Response"
}
else if( getHost.contains("virinf0002vt.metest.local"))
{
// return the name of the response you want to dispatch
return "U-Env-Response"
}
Header:
-----------
POST /ArrangementService HTTP/1.1
Connection: keep-alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Host: virinf0002vt.metest.local:8081
Accept-Encoding: gzip,deflate
Content-Length: 1629
Content-Type: application/soap+xml;charset=UTF-8;action="MEB_AS_ArM_ArrangementES_WS_provider_v3_ArrangementService_Binder_getArrangementList"
Thanks and Regards
-------------------------
Senthil kumar. M
Hi,
> but it did not work.
More details, please?
> help me in fixing below code.
What exactly needs to be fixed?
Does this help: https://community.smartbear.com/t5/SoapUI-Pro/How-to-get-header-data-from-a-RAW-response-into-a-parameter/m-p/27489/highlight/true#M13266 ?