SOAPHandler和Spring Autowire

时间:2014-12-18 12:49:41

标签: spring autowired soaphandler

我试图将Spring Service注入SOAPHandler,但引用始终为null。

我尝试扩展SpringBeanAutowiringSupport并使用:

public class FuelServiceSOAPHandlerBase extends SpringBeanAutowiringSupport implements SOAPHandler<SOAPMessageContext>, InitializingBean {
    @Autowired
    private AuthenticationService authenticationService;

    @Override
    @PostConstruct
    public void afterPropertiesSet() throws Exception {
        LOG.info("AuthenticationHandler - PostConstruct");
        SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
    }
    ....
}

它不起作用,authenticationService始终为null。我也试图让Bean抛出

authenticationService = WebApplicationContextUtils.getWebApplicationContext(((HttpServletRequest)context.getMessage().getProperty(MessageContext.SERVLET_REQUEST)).getSession().getServletContext()).getBean(FuelAuthenticationService.class);

但ServletRequest为空。我正在执行Webservice-Call抛出SOAPUI。

有人知道错误是什么吗?

由于

1 个答案:

答案 0 :(得分:2)

我解决了使用@Resource而不是@Autowire