Search code examples
javaweb-servicesapache-camelcxfjbossfuse

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?


Solution

  • 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.