1

I'm trying to inject a Spring Service into a SOAPHandler but the reference is always null.

I tried extending SpringBeanAutowiringSupport and using:

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);
    }
    ....
}

It does not work, authenticationService is always null. I tried also to get the Bean throw

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

But the ServletRequest is null. I'm executing the Webservice-Call throw SOAPUI.

Does anybody knows what the error is?

Thanks

Rubén
  • 427
  • 1
  • 9
  • 23

1 Answers1

3

I solved using @Resource and not @Autowire

Rubén
  • 427
  • 1
  • 9
  • 23