2016-12-01 274 views
0

我有一个Web应用程序,它使用apache cxf和spring启动提供soap web服务。因此,我的类路径中没有xml文件来配置我的bean,它们都是在java配置中配置的。我想使用cxf中的ws-security设置身份验证。 所以我想知道是否有针对SAAJInInterceptor和WSS4JInInterceptor豆类例如像这样的Java配置:SAAJInInterceptor和WSS4JInInterceptor beans的Java配置

@Bean 
public ServletRegistrationBean cxfServlet() { 
    ServletRegistrationBean servlet = new ServletRegistrationBean(new CXFServlet(), "/services/*"); 
    servlet.setLoadOnStartup(1); 
    return servlet; 
} 

回答

0

你只需要在您创建的端点添加拦截器:

Map<String,Object> interceptorConfig = new HashMap<String,Object>(); 
// set the properties of you WSS4J config 
// ... 
WSS4JInInterceptor myInterceptor = new WSS4JInInterceptor(interceptorConfig); 
myEndpoint.getInInterceptors().add(myInterceptor); 

另一种解决方案是通过使用@InInterceptors

+0

感谢的注解您的及时反应......我该怎么办它使用@InInterceptors注释? – FiokoSoft