2014-06-25 75 views
0

我有以下代碼,它不起作用。 CXF報告沒有找到服務,如果我直接通過http://domain:8080/api/cxf/LotService訪問它,我會得到'沒有找到服務'。我在Tomcat中使用最新的CXF和Spring 4。已配置CXF和Spring但CXF報告'找不到服務'

@Configuration 
@ImportResource({ "classpath:META-INF/cxf/cxf.xml" }) 
public class CXFConfiguration { 

    @Autowired 
    ILotService lotService; 

    @Bean 
    public Endpoint lotService() { 
     EndpointImpl endpoint = new EndpointImpl(SpringBusFactory.getDefaultBus(), lotService); 
     endpoint.setAddress("/LotService"); 
     endpoint.publish(); 

     return endpoint; 
    } 

回答

1

合理配置是這裏

@Configuration 
@Order(3) 
@ImportResource({ "classpath:META-INF/cxf/cxf.xml" }) 
public class CXFConfiguration { 

    @Autowired 
    Bus cxfBus; 


@Bean 
public Endpoint lotServiceEndpointWS() { 
    EndpointImpl endpoint = new EndpointImpl(this.cxfBus, 
      new LotServiceEndpoint()); 
    endpoint.setAddress("/LotService"); 
    endpoint.publish(); 

    return endpoint; 
}