[英]How to get session from cxf out interceptor
I have a cxf "in interceptor" bound to Receive phase that store data into session. 我有一个绑定到接收阶段的cxf“在拦截器中”,该阶段将数据存储到会话中。
MyCxfInInterceptor (In interceptor) MyCxfInInterceptor(在拦截器中)
public class MyCxfInInterceptor extends AbstractSoapInterceptor {
public MyCxfInInterceptor() {
super(Phase.RECEIVE);
}
public void handleMessage(SoapMessage message) throws Fault {
HttpServletRequest request (HttpServletRequest)message.get(AbstractHTTPDestination.HTTP_REQUEST);
HttpSession session = request.getSession(true);
session.setAttribute("foo","bar");
}
}
MyCxfOutInterceptor (Out interceptor) MyCxfOutInterceptor(Out拦截器)
public class MyCxfOutInterceptor extends AbstractSoapInterceptor {
public MyCxfOutInterceptor() {
super(Phase.SEND);
}
public void handleMessage(SoapMessage message) throws Fault {
//TODO Retrieve data from session.
}
}
I want to retrieve theses data into my "out interceptor". 我想将这些数据检索到我的“拦截器”中。 How can i do it ?
我该怎么做 ?
I don't know how to retrieve session from HttpServletResponse. 我不知道如何从HttpServletResponse检索会话。 Maybe the session is not available anymore.
可能该会话不再可用。 Is there any other way to store & retrieve data?
还有其他方法可以存储和检索数据吗?
Spring could be helpful? 春天会有所帮助吗?
You can use the Exchange
, to exchange the data between in and out interceptor 您可以使用
Exchange
,在进出拦截器之间交换数据
In interceptor 在拦截器中
public void handleMessage(SoapMessage message) throws Fault {
message.getExchange().put("foo","bar");
}
Out interceptor 拦截器
public void handleMessage(SoapMessage message) throws Fault {
Object obj = message.getExchange().get("foo");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.