2017-05-26 145 views
0

我需要匹配請求及其相應的響應,所以我試圖將會話ID用於匹配每個請求及其響應。 我在我的構造函數中使用了Phase.PRE_STREAMHttpServletRequest在Apache cxf攔截器中爲null

我試圖把HttpServletRequest和下面的會話ID在我的攔截

public void handleMessage(Message msg) { 
    HttpServletRequest req = (HttpServletRequest)msg.get("HTTP.REQUEST"); 
} 

但我正在逐漸空值。有人能告訴我如何在Apache cxf中使用HttpServletRequest嗎?

我是否需要設置會話ID,同時創造client.I創建我的客戶,如下

JAXRSClientFactoryBean sf = new JAXRSClientFactoryBean(); 
sf.setResourceClass(CustomerService.class); 
sf.setAddress("http://localhost:9000/"); 
BindingFactoryManager manager = sf.getBus().getExtension(BindingFactoryManager.class); 
JAXRSBindingFactory factory = new JAXRSBindingFactory(); 
factory.setBus(sf.getBus()); 
manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, factory); 
CustomerService service = sf.create(CustomerService.class); 
WebClient wc = sf.createWebClient(); 

回答

0

實現SOAP處理程序,像這樣:

public class SOAPRequestHandler implements SOAPHandler<SOAPMessageContext> 

和實現處理程序,如下所示:

public boolean handleMessage(SOAPMessageContext msgContext) 
{ 
    HttpServletRequest request = (HttpServletRequest) msgContext.get("HTTP.REQUEST"); 
... 
} 
相關問題