I am trying to add asserions using script method for Response header, can you please suggest how to add it .
Currently addes as below but actually I need to value in header.
assert messageExchange.responseHeaders["Connection"] != null
Also I have to validate error response i.e. 401 , 400 & 500 from response , please suggest how can this achive.
You can use below code to get the header value and validate the same according to your need :
def expectedHeader = ["Header"]
def headers = messageExchange.response.responseHeaders
def actualHeader = headers['Actual Header from response']
assert expectedHeader == actualHeader