#spring #cxf #spring-java-config
#spring #cxf #spring-java-config
Вопрос:
У меня есть следующий код, и он не работает. CXF сообщает, что службы не найдены, и если я обращаюсь к нему напрямую http://domain:8080/api/cxf/LotService
, я получаю сообщение «Служба не найдена». Я использую последнюю версию CXF и Spring 4 в Tomcat.
@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;
}