Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access Servlet Session in CXF Interceptor?

Tags:

java

jax-ws

cxf

I have an "in" CXF Interceptor, I want to access the the Servlet Session in its handleMessage() method. My Interceptor extends AbstractPhaseInterceptor.

I want to access the session to store some info about the user as my web service client maintains sessions.

I can already access the session in my web services.

like image 472
Bahaa Zaid Avatar asked Jan 11 '11 11:01

Bahaa Zaid


People also ask

What is CXF interceptor?

Interceptors are the fundamental processing unit inside CXF. When a service is invoked, an InterceptorChain is created and invoked. Each interceptor gets a chance to do what they want with the message. This can include reading it, transforming it, processing headers, validating the message, etc.

What is Apache CXF used for?

Apache CXF™ is an open source services framework. CXF helps you build and develop services using frontend programming APIs, like JAX-WS and JAX-RS. These services can speak a variety of protocols such as SOAP, XML/HTTP, RESTful HTTP, or CORBA and work over a variety of transports such as HTTP, JMS or JBI.

What is JaxWsProxyFactoryBean?

Class JaxWsProxyFactoryBeanFactory for creating JAX-WS proxies, This class provides access to the internal properties used to set-up proxies. Using it provides more control than the standard JAX-WS APIs.


1 Answers

You should be able to do

HttpServletRequest req = (HttpServletRequest)message.get("HTTP.REQUEST");

to get the HttpServletReqest where you can then grab the session from it.

like image 114
Daniel Kulp Avatar answered Oct 21 '22 03:10

Daniel Kulp