Getting "HttpServletRequest" in soapMessageContext - Axis Handler
Asked Answered
T

1

6

I am trying to get "HttpServletRequest" in an AxisHandler's "handleMessage" method. My AxisHandler implements "SOAPHandler" as seen below code..

I need to get "HttpServletRequest" in "InBoundDirection", but it returns "null".

How can I get "HttpServletRequest" in "InBoundDirection" of SOAPHandler ?

Thank you..

@Override
public boolean handleMessage(SOAPMessageContext soapMessageContext) {
    boolean direction = ((Boolean) soapMessageContext.get(SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY)).booleanValue();        
    if (direction) {
        System.out.println("direction = outbound");
    } else {
        System.out.println("direction = inbound");
        HttpServletRequest servletReq=(HttpServletRequest) soapMessageContext.get(MessageContext.SERVLET_REQUEST);
        // BECAUSE servletReq is null the following line returns a "nullPointerException"
        System.out.println(servletReq.getRemoteHost()); 
    }
    return true;
}
Truditrudie answered 5/10, 2011 at 7:18 Comment(0)
E
0

See this post jax ws getting client ip for a very good explanation. Looks like if one wants to have a generic handler (in my case to extract the client certificate) one needs to implement the same logic for both EE container hosted webservices as well as SE hosted containers.

Elmaleh answered 22/7, 2016 at 13:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.