title: How to call a third party webservice using Apache camel using cxf componnet
body: <p>I went through the example on Apache camel website and camel in action and both focus heavily on exposing a webservice. The only example I found online does not work.</p>
  
  <p>I am trying to access a third party webservice wsdl  - <a href="http://www.webservicex.net/CurrencyConvertor.asmx?WSDL" rel="nofollow">http://www.webservicex.net/CurrencyConvertor.asmx?WSDL</a></p>
  
  <p>This service has a operation/method that calculates the currency rate. The operation name is "ConversionRate".</p>
  
  <p>I defined the route like this -</p>
  
  <pre><code>      &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!-- Configures the Camel Context--&gt;
  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:camel="http://camel.apache.org/schema/spring"
         xmlns:cxf="http://camel.apache.org/schema/cxf"
         xsi:schemaLocation="
         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
         http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"&gt;
  
  
    &lt;camelContext xmlns="http://camel.apache.org/schema/spring"&gt;
  
      &lt;route&gt;
          &lt;description&gt;here is a sample which processes the input files
           (leaving them in place - see the 'noop' flag)
           then performs content based routing on the message using XPath&lt;/description&gt;
          &lt;from uri="file:src/data/order?noop=true"/&gt;
          &lt;log message="${body}"/&gt;
  
          &lt;to uri="cxf://http://www.webservicex.net/CurrencyConvertor.asmx?wsdlURL=http://www.webservicex.net/CurrencyConvertor.asmx?wsdl&amp;amp;serviceName=CurrencyConvertor&amp;amp;portName=http://www.webserviceX.NET/tns:CurrencyConvertorSoap&amp;amp;dataFormat=MESSAGE"/&gt;
          &lt;log message="${body}"/&gt;
      &lt;/route&gt;
  &lt;/camelContext&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>I have defined the sample payload xml as - </p>
  
  <pre><code>&lt;order&gt;
          &lt;Id&gt;1&lt;/Id&gt;
          &lt;Price&gt;10.00&lt;/Price&gt;
          &lt;Quantity&gt;2&lt;/Quantity&gt;
  &lt;/order&gt;
  </code></pre>
  
  <p>I am getting this error when I run this example.</p>
  
  <pre><code>   Error occurred while running main from: org.apache.camel.spring.Main
  java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.apache.camel.maven.RunMojo$1.run(RunMojo.java:440)
      at java.lang.Thread.run(Thread.java:744)
  Caused by: org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: Endpoint[cxf://http://www.webservicex.net/CurrencyConvertor.asmx?dataFormat=MESSAGE&amp;portName=http%3A%2F%2Fwww.webserviceX.NET%2Ftns%3ACurrencyConvertorSoap&amp;serviceName=CurrencyConvertor&amp;wsdlURL=http%3A%2F%2Fwww.webservicex.net%2FCurrencyConvertor.asmx%3Fwsdl]. Reason: org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service CurrencyConvertor.
      at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:395)
      at org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:114)
      at org.apache.camel.impl.ProducerCache.startProducer(ProducerCache.java:145)
      at org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:175)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
      at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
      at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
      at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
      at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
      at org.apache.camel.processor.interceptor.TraceInterceptor.doStart(TraceInterceptor.java:358)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
      at org.apache.camel.processor.WrapProcessor.doStart(WrapProcessor.java:52)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
      at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
      at org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1064)
      at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:41)
      at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:28)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
      at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
      at org.apache.camel.processor.interceptor.DefaultChannel.doStart(DefaultChannel.java:153)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
      at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:85)
      at org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:938)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
      at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
      at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
      at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
      at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
      at org.apache.camel.processor.UnitOfWorkProcessor.doStart(UnitOfWorkProcessor.java:88)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
      at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
      at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
      at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
      at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
      at org.apache.camel.impl.RouteService.startChildService(RouteService.java:322)
      at org.apache.camel.impl.RouteService.warmUp(RouteService.java:151)
      at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:2000)
      at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:1928)
      at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1716)
      at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1597)
      at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1453)
      at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:179)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1421)
      at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:228)
      at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:118)
      at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:283)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
      at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:327)
      at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:941)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:475)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:93)
      at org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:186)
      at org.apache.camel.spring.Main.doStart(Main.java:140)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      at org.apache.camel.main.MainSupport.run(MainSupport.java:141)
      at org.apache.camel.main.MainSupport.run(MainSupport.java:332)
      at org.apache.camel.spring.Main.main(Main.java:73)
      ... 6 more
  Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service CurrencyConvertor.
      at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:139)
      at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:412)
      at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:534)
      at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:248)
      at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
      at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
      at org.apache.camel.component.cxf.CxfEndpoint.createClient(CxfEndpoint.java:527)
      at org.apache.camel.component.cxf.CxfProducer.doStart(CxfProducer.java:76)
      at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
      at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
      at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:393)
      ... 88 more
  *************************************.
  </code></pre>