已配置CXF和Spring,但CXF报告“未找到任何服务”

时间:2014-06-25 06:20:17

标签: spring cxf spring-java-config

我有以下代码但它不起作用。 CXF报告未找到任何服务,如果我直接通过http://domain:8080/api/cxf/LotService访问它,我会收到“未找到服务”。我在Tomcat中使用最新的CXF和Spring 4.

@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 个答案:

答案 0 :(得分: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;
}