Stubborn
Stubborn

Reputation: 330

In SpringBoot web service endpoint, how do I access http headers?

I have a class annotated with @Endpoint and a handler method

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getWeatherRequest")
@SoapAction("http://foo/domain/getWeatherRequest")
@ResponsePayload
public GetWeatherResponse getWeatherRequest(@RequestPayload GetWeatherRequest request) {
    // I want to get HTTP header (Not SOAP Header) here
}

Upvotes: 0

Views: 647

Answers (2)

Purushotham
Purushotham

Reputation: 3818

You can use RequestHeader annotation in your method to access http headers, you can specify whether header is mandatory or optional using required attribute

@RequestHeader(value = "ConfigId", required = true) String configId

Upvotes: 0

Bash
Bash

Reputation: 4450

Try using the @RequestHeader annotation

@SoapAction("http://foo/domain/getWeatherRequest")
@ResponsePayload
public GetWeatherResponse getWeatherRequest(@RequestPayload GetWeatherRequest request, 
@RequestHeader("header-name") String header) {
   
}

Upvotes: 1

Related Questions