web services - How to use Spring Autowired in a custom cxf interceptor? -
i seem run small issue when using @autowired custom cxf interceptor. use case want log soap messages , send these using amqp system. process works normal services etc. whatever do, needed properties not autowired , stay null.
i checked spring di log , context scanned , pickedup, missing?
is possible in cxf interceptors?
@component public class logininterceptor extends abstractsoapinterceptor { private @value("#{rabbitmqproperties['rabbitmq.binding.log.soap']}") string binding; @autowired amqptemplate amqptemplate; public logininterceptor() { super(phase.receive); } @override public void handlemessage(soapmessage soapmessage) throws fault { logit(soapmessage); } private void logit(soapmessage message) throws fault { // rest of code omitted...!!! amqptemplate.convertandsend(binding, buffer.tostring()); } }
you can't mix @ininterceptors (a cxf annotation) and @component (a spring annotation). create 2 separate instances of interceptor: 1 dependencies getting injected spring, , 1 created cxf. (you providing class names in @ininterceptors annotation, not bean id, cxf has no way of knowing created instance in spring context.)
remove @ininterceptors annotation and, in addition component scan:
<context:component-scan base-package="org.example.config"/> you need in application context:
<jaxws:endpoint id="mywebservice" address="/mywebservice"> <jaxws:ininterceptors> <ref bean="myininterceptor" /> </jaxws:ininterceptors> </jaxws:endpoint>
Comments
Post a Comment