> -----Original Message-----
> From: Loïc ¨Paillotin [mailto:[email protected]]
> Sent: Monday, January 31, 2011 1:46 PM
> To: [email protected]
> Subject: CXF and spring
> 
> Hello,
> 
> I am fairly new to CXF and Spring, and have been tasked to port an
> existing
> XFire Soap service to CXF.
> 
> Right now, my service seems to be correctly configured: I can access
> the
> WSDL which seems correct (minor differences but I'll worry about that
> later).
> 
> The problem I have is that some beans that were injected by spring in
> my
> service under XFire are not injected in my CXF implementation.
> 
> My implementation class looks something like this:
> 
> @WebService(endpointInterface = "demo.cxf.ServiceCxf")
> public class ServiceCxfImpl implements ServiceCxf {
>     private SearchService search;
>     private SearchSpec spec;
>     /**
>      * @inheritDoc
>      */
>     public SearchResult[] searchSimple(SearchSpec spec) {
>         return search.searchSimple(spec);
>     }
> 
>  The problem is that my SearchService bean is never instantiated.

You've said two things here.  You've said beans are not "injected", and then 
you said the bean is not "instantiated".  Which do you mean?  Those are two 
different things.

I'm guessing you meant the first, that your SearchService bean is instantiated, 
but not injected into your ServiceCxfImpl instance.

In that case, did you try adding an "@Autowired" annotation before the "search" 
instance variable?

> My config:
> searchService.xml
> <beans xmlns="http://www.springframework.org/schema/beans";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xmlns:jaxws="http://cxf.apache.org/jaxws";
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd";>
> 
> <import resource="classpath:META-INF/cxf/cxf.xml" />
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>  <bean id="aegisBean"
> class="org.apache.cxf.aegis.databinding.AegisDatabinding"
> scope="prototype"/>
>  <bean id="jaxws-and-aegis-service-factory"
>     class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
>     scope="prototype">
>         <property name="dataBinding" ref="aegisBean"/>
>                  <property name="serviceConfigurations">
>                      <list>
>                        <bean
> class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
>                        <bean
> class="org.apache.cxf.aegis.databinding.XFireCompatibilityServiceConfig
> uration"/>
>                        <bean
> class="org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
>                     </list>
>                  </property>
> </bean>
> 
> 
>   <bean id="searchService"
>         class="demo.cxf.SearchService"/>
> 
> 
> <jaxws:endpoint id="ServiceCxf"
>    implementor=demo.cxf.ServiceCxfImpl"
>    address="/searchServiceCxf">
>    <jaxws:serviceFactory>
>    <ref bean='jaxws-and-aegis-service-factory'/>
>    <ref bean='searchService'/>
>    </jaxws:serviceFactory>
> 
> 
> </jaxws:endpoint>
> </beans>
> 
> In web.xml, my servlet is simply configured like so:
> 
>  <servlet>
>     <servlet-name>CXFServlet</servlet-name>
>     <display-name>CXF Servlet</display-name>
>     <servlet-class>
>         org.apache.cxf.transport.servlet.CXFServlet
>     </servlet-class>
>   </servlet>
> 
>  <servlet-mapping>
>     <servlet-name>CXFServlet</servlet-name>
>     <url-pattern>/cxf/*</url-pattern>
>   </servlet-mapping>
> 
> 
> I have no idea why I can't inject the bean using spring. I tried lots
> of
> different things that probably make no sense, and I am a bit lost to be
> honest.
> Could somebody point me in the right direction?
> 
> Thanks a lot in advance for your help.
> 
> --
> Loïc Paillotin

Reply via email to