cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve a value from the request header?

SOLVED
Highlighted
Contributor

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: How to retrieve a value from the request header?

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-para... ?

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================

View solution in original post

2 REPLIES 2
Community Hero

Re: How to retrieve a value from the request header?

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-para... ?

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================

View solution in original post

Contributor

Re: How to retrieve a value from the request header?

HI Alex,

 

Thanks for your support, the documnet provided was helpfull to me. 

 

Regards

Senthil kumar. M

New Here?
Join us and watch the welcome video:
Watch the new Interview