title: Call web service from Camel
body: <p>I would like to call web service from Camel. But I receive null everytime I call the service.
  Could you please help me finding a solution?</p>
  
  <p>The service is running on tomcat and I can test it with soapUI. Here is the request from SoapUI.</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"     xmlns:hel="http://helloworld.localhost"&gt;
      &lt;soapenv:Header/&gt;
         &lt;soapenv:Body&gt;
            &lt;hel:HelloWorldRequest&gt;
                 &lt;hel:input&gt;Pavel&lt;/hel:input&gt;
            &lt;/hel:HelloWorldRequest&gt;
         &lt;/soapenv:Body&gt;
      &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>and the response returns Hello Pavel. 
  I followed the CamelInAction guide with creating contract first web service. 
  I am able to run the route which reads a file and send it to web service.</p>
  
  <p>The code of the route is the following.</p>
  
  <pre><code>public class FileToWsRoute extends RouteBuilder {
  public void configure() { 
      from("file://src/data?noop=false")
      .process(new FileProcessor())
      .to("cxf:bean:helloWorld");
      }
  
  }
  </code></pre>
  
  <p>The FileProcessor class looks like this:</p>
  
  <pre><code>public class FileProcessor implements Processor {
  
  public void process(Exchange exchange) throws Exception {
  
      System.out.println("We just downloaded: " 
              + exchange.getIn().getHeader("CamelFileName"));
      String text = 
      "&lt;?xml version='1.0' ?&gt;" 
      +"&lt;soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:hel=\"http://helloworld.localhost\"&gt;"
      +"&lt;soapenv:Header/&gt;"
      +   "&lt;soapenv:Body&gt;"
      +     " &lt;hel:HelloWorldRequest&gt;"
      +        " &lt;hel:input&gt;WhatsUP&lt;/hel:input&gt;"
      +     " &lt;/hel:HelloWorldRequest&gt;"
      +   "&lt;/soapenv:Body&gt;"
      +"&lt;/soapenv:Envelope&gt;";
  
      exchange.getIn().setBody(text);
  }
  }
  </code></pre>
  
  <p>In next version I would like to generate a request through the objects generated by cxf-codegen-plugin (HalloWorld.java, HelloWorldImpl.java, HelloWorldRequest.java, HelloWorldResponse.java, HelloWorldService.java, ObjectFactory.java, package-info.java).</p>
  
  <p>In the camel-cxf.xml I have:</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:cxf="http://camel.apache.org/schema/cxf"
     xsi:schemaLocation="
       http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://camel.apache.org/schema/cxf 
       http://camel.apache.org/schema/cxf/camel-cxf.xsd"&gt;
  
    &lt;import resource="classpath:META-INF/cxf/cxf.xml"/&gt;
    &lt;import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/&gt;
    &lt;import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml"/&gt;
  
    &lt;cxf:cxfEndpoint id="helloWorld"
                 address="http://localhost:8080/ode/processes/HelloWorld"
                 serviceClass="localhost.helloworld.HelloWorld"
                 wsdlURL="wsdl/HelloWorld.wsdl"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>To read response from the web service I am using this route.</p>
  
  <pre><code>public class WsToQueueRoute extends RouteBuilder {
      public void configure() { 
      from("cxf:bean:helloWorld")
      .to("seda:incomingOrders")
      .transform().constant("OK");
      }
  
  }
  </code></pre>
  
  <p>The last route gets data from seda... </p>
  
  <pre><code>public class QueueToProcessRoute extends RouteBuilder {
  public void configure() { 
      from("seda:incomingOrders")
      .process(new PrintResult());
      }
  
  }
  </code></pre>
  
  <p>...and prints the result.</p>
  
  <pre><code>public class PrintResult implements Processor {
  
  public void process(Exchange exchange) throws Exception {
  
      System.out.println("Data received: " 
              + exchange.getIn().getBody(String.class));
  }
  
  }
  </code></pre>
  
  <p>The output from the execution is:
  Data received: null</p>
  
  <p>I would expect some XML file which I could parse with cxf objects. Could you please help me finding the problem? </p>
  
  <p>Thank you </p>
  
  <p>Pavel</p>