【问题标题】:I am trying to calling sample web service from apache camel but getting below error-我正在尝试从 apache camel 调用示例 Web 服务,但低于错误-
【发布时间】:2016-08-10 07:04:22
【问题描述】:

这是我收到的错误 - java.lang.RuntimeException: 找不到地址的管道启动器:cxf:http://www.webservicex.net/stockquote.asmx 和传输:http://schemas.xmlsoap.org/soap/http

我尝试了所有可能的在线解决方案,但每次都收到相同的回复。

下面是RouteBuilder类

 //@Component
 public class CamelRouterImpl extends RouteBuilder {

     ProducerTemplate template;
     public CamelRouterImpl(ProducerTemplate template) {
         // TODO Auto-generated constructor stub
         this.template = template;
     }

     @
     Override
     public void configure() throws Exception {
         // TODO Auto-generated method stub

         System.out.println("---- RouteBuilder");
         CxfComponent cxfComponent = new CxfComponent(getContext());
         String url = "cxf:http://www.webservicex.net/stockquote.asmx";


         CxfEndpoint serviceEndpoint = new CxfEndpoint(url, cxfComponent);
         serviceEndpoint.setServiceFactory(ObjectFactory.class);
         serviceEndpoint.setServiceClass(GetQuote.class);

         GetQuote quote = new GetQuote();
         quote.setSymbol("ibm");

         Exchange exchange = template.send(serviceEndpoint, new Processor() {

             @
             Override
             public void process(Exchange exchange) throws Exception {
                 // TODO Auto-generated method stub

                 exchange.getIn().setBody(quote);
             }
         });

         org.apache.camel.Message out = exchange.getOut();
         System.out.println(out.getBody());
     }
 }

骆驼上下文类

public class CamelContextImpl {


     public void run() {
         // TODO Auto-generated method stub


         CamelContext context = new DefaultCamelContext();

         try {
             context.start();
             ProducerTemplate template = context.createProducerTemplate(0);

             template.start();
             context.addRoutes(new CamelRouterImpl(template));

         } catch (Exception e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         } finally {
             //to stop consumer and route
             //ConsumerTemplate.stop();
             if (context != null) {

                 try {
                     context.stop();
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
             }
         }
     }
 }

Gradle 构建文件

 buildscript {
         repositories {
             mavenCentral()
         }
         dependencies {
             classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.2.RELEASE")
         }
     }

 repositories {
     mavenCentral()
 }

 apply plugin: 'java'
 apply plugin: 'eclipse'
 apply plugin: 'spring-boot'
 apply plugin: 'base'

 sourceCompatibility = 1.8
 targetCompatibility = 1.8

 dependencies {

compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.3.5.RELEASE'
compile group: 'org.apache.camel', name: 'camel-core', version: '2.17.0'
compile group: 'org.apache.camel', name: 'camel-cxf', version: '2.17.0' 
compile group: 'axis', name: 'axis-wsdl4j', version: '1.5.1'
compile group: 'commons-lang', name: 'commons-lang', version: '2.3' 
compile group: 'org.apache.cxf', name: 'cxf-rt-bindings-soap', version: '3.1.7'
compile group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxws', version: '3.1.7'
compile group: 'org.apache.cxf', name: 'cxf-rt-ws-policy', version: '3.1.7'
compile group: 'org.apache.cxf', name: 'cxf-rt-transports-http-jetty', version: '3.1.7'
compile group: 'org.apache.cxf', name: 'cxf-bundle', version: '3.0.0-milestone2'    

}

【问题讨论】:

  • 你的类路径中有所有必要的 jar 包吗?有关更多信息,请参阅stackoverflow.com/questions/7611803/…。也许传输 https jar 丢失了
  • 感谢您的回复,但我正在使用所有必需的 jar 和这个 - cxf-rt-transports-http-jetty。下面是我在示例项目中使用的 jar -spring-boot-starter-web,camel-core,camel-cxf,axis-wsdl4j,commons-lang,cxf-rt-bindings-soap,cxf-rt-frontend-jaxws, cxf-rt-ws-policy,cxf-rt-transports-http-jetty,cxf-bundle.

标签: java spring-boot web-services apache-camel cxf


【解决方案1】:

尝试从 URL 的开头删除 cxf://cxf:。 您无需指定骆驼组件,因为您使用CxfEndpoint 来构造调用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多