tvshajeer
tvshajeer

Reputation: 1329

How to get Host name and port from CXF Message

I tried to get hostname and port using

Message message = PhaseInterceptorChain.getCurrentMessage(); HttpServletRequest request = (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST); request.getRemoteAddr()

but it is giving the client details.

How can we get the host name and port from cxf Message?

Upvotes: 2

Views: 1091

Answers (1)

tvshajeer
tvshajeer

Reputation: 1329

I've got the solution

Map<String, List<String>> headers = (Map<String, List<String>>) message.get(Message.PROTOCOL_HEADERS); String host = headers.get("host").get(0);

This will get you the host ip with port.

Upvotes: 2

Related Questions