使用Spring-Java在camel中配置cxf

时间:2014-06-02 13:58:40

标签: java spring cxf apache-camel

我有一个Camel-Environment,它是通过Java配置的:

@Configuration

@ImportResource({ "classpath:META-INF/cxf/cxf.xml" })
public class MyConfiguration extends AnotherConfiguration {

    @Autowired
    private SomeClass someClass;
    ...

    @Bean(name = "beantest")
    public CxfEndpoint beanTest() {
        final CxfEndpoint cxfEndpoint = new CxfEndpoint();
        cxfEndpoint.setAddress("http://localhost:9000/myservice");
        cxfEndpoint.setServiceClass(TestBean.class);
        return cxfEndpoint;
    }
}

我希望它创建一个骆驼路线,它可以收听网络服务器,由我实现

public void configure() {
    this.from("cxf:bean:beantest")
        .log("Bean called successfully")
        .end();
}

我真的无法让这个工作。我相信(我希望),我的问题只是在'beanTest()'中的配置中的某个地方而且只缺少该代码。

问题: 启动Tomcat我收到一个异常,堆栈引导我到这些行:

Caused by: java.io.IOException: Cannot find any registered HttpDestinationFactory from the Bus.
    at org.apache.cxf.transport.http.HTTPTransportFactory.getDestination(HTTPTransportFactory.java:296)
    at org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:142)
    at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:93)

第二 我不确定,TestBean究竟是什么样的:

@WebService(name = "testingTheBean", targetNamespace = "http://webservices.test/")
public class TestBean {
    @WebMethod()
    public void wscall(@WebParam(name = "parameter") final String parameter) {
        System.out.println("WS-Call successfull");
    }
}

抱歉,Spring对我来说是新手,cxf,camel和spring-java-config的例子很难找到。

2 个答案:

答案 0 :(得分:4)

您可以查看cxf-rt-transport-http和cxf-rt-transport-http-jetty是否在您的类路径中?

答案 1 :(得分:1)

在maven pom.xml中导入cxf-rt-transports-http-jetty

这将解决问题。

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http-jetty</artifactId>
    <version>3.1.6</version>
</dependency>