Calling a JAX-WS Web service from Camel

In this tutorial we will demonstrate how to invoke from Camel a JAX-WS Web service running on WildFly, without writing a single line of code.

First of all, here is the Web service implementation:

import javax.jws.WebService;
public class SimpleWebSevice implements Simple {

	public String hello(String s) {
		System.out.println("Called Web service with: "+s);
		return "Hello "+s;


And its interface:

public interface Simple {
      public String hello(String s);

The Web service is packaged in a Web application named DemoWS.war therefore its WSDL is available as: http://localhost:8080/DemoWS/SimpleWebService?wsdl

Creating the Camel application

Now create a new Camel Maven project as described in this tutorial:  Using maven to set up a Camel project

We can describe the Camel route either as Java DSL or via Spring. Using spring, we will create the file camel-context.xml under src/main/resources/META-INF/spring

<beans xmlns=""
	xmlns:xsi="" xmlns:camel=""

	<cxf:cxfEndpoint id="SimpleWebService"
		address="http://localhost:8080/DemoWS/SimpleWebService" wsdlURL="http://localhost:8080/DemoWS/SimpleWebService?wsdl"
		serviceClass="com.sample.SimpleWebService" />

	<camelContext xmlns="">
		<route id="wsClient">
			<from uri="timer:foo?repeatCount=1" />
				<simple>Hello World!</simple>
			<log message="${body}" />
			<to uri="cxf:bean:SimpleWebService?defaultOperationName=hello" />
			<to uri="mock:result" />


In the first part of the configuration file we have declared the cxf: component, which provides integration with Apache CXF for connecting to JAX-WS services hosted in CXF. Then, our route which:

1) Starts with a Timer which is executed once

2) Sets the message body

3) Logs Message

4) Invokes the hello method of SimpleWebService (passing the Message body)

5) Sends the output to the mock component which cab be used by unit tests

camel jaxws example tutorial

Provided that you have included the Camel Maven plugin in the pom.xml:


Then you can start the route with:

mvn camel:run