Calling a JAX-WS Web service from Camel

To invoke a JAX-WS web service running on WildFly from Apache Camel, you can utilize the Camel CXF component, which provides integration with the Apache CXF web service framework. Here’s a step-by-step guide on how to accomplish this.

Defining the JAX-WS Web service

Firstly, we will create the JAX-WS Web Service. This is a simple 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:   Setting up a Camel project with Maven

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 web services integration example

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

<?xml version="1.0" encoding="UTF-8"?><plugin>

Then you can start the route with:

mvn camel:run

Source code for this tutorial:

Found the article helpful? if so please follow us on Socials
Twitter Icon       Facebook Icon       LinkedIn Icon       Mastodon Icon