Apache camel 从Camel调用JAX-WS Web服务

Apache camel 从Camel调用JAX-WS Web服务,apache-camel,cxf,Apache Camel,Cxf,我需要调用WildFly 8上提供的JAX-WS Web服务。我从一个简单的例子开始。以下是我的Web服务: import javax.jws.WebService; @WebService public class HelloWorld implements Hello{ @Override public String greet(String s) { return "Hello "+s; } } WSDL可从以下网址获得: 看看Tomcat

我需要调用WildFly 8上提供的JAX-WS Web服务。我从一个简单的例子开始。以下是我的Web服务:

import javax.jws.WebService;
@WebService
public class HelloWorld implements Hello{

    @Override
    public String greet(String s) {

        return "Hello "+s;
    }

}
WSDL可从以下网址获得:

看看Tomcat CXF示例,我编写了以下路径:

public class CamelRoute extends RouteBuilder {


    private String uri = "cxf:http://localhost:8080/helloWorld?serviceClass=com.sample.HelloWorld";

    @Override
    public void configure() throws Exception {
        from(uri)
            .to("log:input")
            .recipientList(simple("direct:${header.operationName}"));

        from("direct:greet")
            .process(new Processor() {
                public void process(Exchange exchange) throws Exception {

                    String id = exchange.getIn().getBody(String.class);
                    exchange.getOut().setBody(id);
                }
            })
            .to("log:output");


    }
}
通过在驼峰上下文中运行上述代码,将返回以下错误:

Exception in thread "main" org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route[[From[cxf:http://localhost:8080/helloWorld?serviceClas... because of Failed to resolve endpoint: cxf://http://localhost:8080/helloWorld?serviceClass=com.sample.HelloWorld due to: No component found with scheme: cxf
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:177)
    at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:731)
    at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1803)
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1589)
    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1453)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1421)
    at com.sample.Main.main(Main.java:15)
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: cxf://http://localhost:8080/helloWorld?
serviceClass=com.sample.HelloWorld原因:未找到具有scheme:cxf的组件

看来我甚至不能调用它。有什么帮助吗? Thanks


org.apache.camel
骆驼型cxf

您需要将camel cxf组件添加到类路径中。如果您使用Maven,则将其添加为依赖项。如果您感兴趣,下面是一个示例,它完全满足您的请求。如果您想从camel route调用web服务,则需要使用to(“cxf:xxx”)而不是from(“cxf:xxx”)。请详细解释您的答案
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-cxf</artifactId>
</dependency>