Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training

    Featured resources

    • Open Source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Configure SOAP web services with Apache Camel on Quarkus

May 22, 2024
Luis Falero Otiniano
Related topics:
JavaQuarkus
Related products:
Red Hat build of Apache CamelRed Hat build of Quarkus

    This article explores how to integrate SOAP and REST services using Quarkus and Apache Camel. Through practical examples, we will learn how to create a Quarkus project, configure and consume SOAP services, and expose RESTful endpoints. Additionally, we will see how to manage JSON data serialization and deserialization using Camel Quarkus.

    Quarkus project creation

    For project configuration, it is required to create the application named code-with-quarkus-camel-soap, which will be using Quarkus 3.2 with Apache Camel version 4.0.

    Review the compatibility matrix.

    There are two options to carry out this configuration, detailed below.

    Creation through the web interface

    Access the link https://code.quarkus.redhat.com and fill in the required information as shown in Figure 1. Then, click the Generate your application button to download the application's base source.

    Figure 1: Start coding Quarkus
    Figure 1: Start coding Quarkus
    Figure 1: Start coding Quarkus.

    Configuration of the settings.xml and creation via command line

    Another alternative is to configure the settings.xml file to add version 3.2 of Quarkus and then create the application using the command line:

    vim ~/.m2/settings.xml
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/xsd/settings-1.0.0.xsd">
        <profiles>
            <profile>
                <id>redhat-ga-all-repository</id>
                <repositories>
                    <repository>
                        <id>redhat-ga-all-repository</id>
                        <name>Red Hat GA (all)</name>
                        <url>https://maven.repository.redhat.com/ga/</url>
                        <layout>default</layout>
                        <releases>
                            <enabled>true</enabled>
                            <updatePolicy>never</updatePolicy>
                        </releases>
                        <snapshots>
                            <enabled>false</enabled>
                            <updatePolicy>never</updatePolicy>
                        </snapshots>
                    </repository>
                </repositories>
                <pluginRepositories>
                    <pluginRepository>
                        <id>redhat-ga-all-repository</id>
                        <name>Red Hat GA repository (all)</name>
                        <url>https://maven.repository.redhat.com/ga/</url>
                        <layout>default</layout>
                        <releases>
                            <enabled>true</enabled>
                            <updatePolicy>never</updatePolicy>
                        </releases>
                        <snapshots>
                            <enabled>false</enabled>
                            <updatePolicy>never</updatePolicy>
                        </snapshots>
                    </pluginRepository>
                </pluginRepositories>
            </profile>
            <profile>
                <id>properties</id>
                <properties>
                    <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
                    <quarkus.platform.group-id>com.redhat.quarkus.platform</quarkus.platform.group-id>
                    <quarkus.platform.version>3.2.10.Final-redhat-00002</quarkus.platform.version>
                </properties>
            </profile>
        </profiles>
        <activeProfiles>
            <activeProfile>redhat-ga-all-repository</activeProfile>
            <activeProfile>properties</activeProfile>
        </activeProfiles>
    </settings>

    Create the project code-with-quarkus-camel-soap:

    mvn com.redhat.quarkus.platform:quarkus-maven-plugin:3.2.10.Final-redhat-00002:create \
      -DprojectGroupId=com.redhat.quarkus.platform \
      -DprojectArtifactId=code-with-quarkus-camel-soap \
      -DplatformVersion=3.2.10.Final-redhat-00002 \
      -DclassName="com.redhat.quarkus.platform.SoapClientResource"

    Quarkus Camel configuration

    Once the project is created, it's necessary to generate the Java classes from the Web Services Description Language (WSDL).

    cd code-with-quarkus-camel-soap

    Within the project directory, create the src/generated/java folder where the Java classes will be generated from XML files and schemas.

    mkdir -p src/generated/java

    Next, create the src/main/resources/wsdl folder where the WSDL file will be stored.

    mkdir -p src/main/resources/wsdl

    Now, it's necessary to configure the pom.xml file to generate the Java classes from the CalculatorService.wsdl file.

    <properties>
      <cxf.version>4.0.2.fuse-redhat-00055</cxf.version>
    </properties>
    <build>    
        <plugin>
          <groupId>org.apache.cxf</groupId>
          <artifactId>cxf-codegen-plugin</artifactId>
          <version>${cxf.version}</version>
          <executions>
            <execution>
              <id>generate-sources</id>
              <phase>generate-sources</phase>
              <configuration>
                <sourceRoot>${basedir}/src/generated/java</sourceRoot>
                <wsdlOptions>
                  <wsdlOption>
                    <wsdl>${basedir}/src/main/resources/wsdl/CalculatorService.wsdl</wsdl>	
                    <faultSerialVersionUID>1</faultSerialVersionUID>
                  </wsdlOption>
                </wsdlOptions>
              </configuration>
              <goals>
                <goal>wsdl2java</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>

    This command uses Maven to automatically generate the necessary Java classes based on the provided WSDL in your project.

    mvn generate-sources

    Then, add the dependency camel-quarkus-cxf-soap, which is a Camel Quarkus extension that provides capabilities to integrate SOAP web services using Apache CXF.

    mvn quarkus:add-extension -Dextension=org.apache.camel.quarkus:camel-quarkus-cxf-soap

    Finally, create the SoapClientConfiguration.java class to automatically map the required configuration properties. This class will facilitate configuring the SOAP client in your application.

    package com.redhat.quarkus.platform;
    
    import io.smallrye.config.ConfigMapping;
    
    @ConfigMapping(prefix = "soap")
    public interface SoapClientConfiguration {
    
        String operationName();
        String operationNamespace();
        String operationAddress();
        String operationWsdlURL();    
    }

    Update the application.properties file with the corresponding values:

    soap.operation-name=Add
    soap.operation-namespace=http://tempuri.org/
    soap.operation-address=http://www.dneonline.com/calculator.asmx
    soap.operation-wsdl-url=wsdl/CalculatorService.wsdl

    To enable the implementation of RESTful services using Apache Camel with Quarkus, it is necessary to add the camel-quarkus-rest dependency. With this extension, you can easily create REST endpoints and efficiently handle HTTP requests in your Quarkus application.

    mvn quarkus:add-extension -Dextension=org.apache.camel.quarkus:camel-quarkus-rest

    Furthermore, to log important messages and events during your application's execution and effectively diagnose issues, it is recommended to add the camel-quarkus-log dependency.

    mvn quarkus:add-extension -Dextension=org.apache.camel.quarkus:camel-quarkus-log

    If you want to enable message routing within the same JVM, you can add the camel-quarkus-direct dependency.

    mvn quarkus:add-extension -Dextension=org.apache.camel.quarkus:camel-quarkus-direct

    Finally, to leverage existing CDI beans in your Quarkus application and use them within your Camel routes to process messages flexibly and efficiently, it is recommended to add the camel-quarkus-bean dependency.

    mvn quarkus:add-extension -Dextension=org.apache.camel.quarkus:camel-quarkus-bean

    Create the SoapClientResource.java class for consuming the SOAP service.

    package com.redhat.quarkus.platform;
    
    import org.apache.camel.builder.RouteBuilder;
    import org.apache.camel.component.cxf.common.message.CxfConstants;
    import org.apache.camel.component.cxf.jaxws.CxfEndpoint;
    import org.tempuri.CalculatorSoap;
    
    import jakarta.enterprise.context.ApplicationScoped;
    import jakarta.enterprise.context.SessionScoped;
    import jakarta.enterprise.inject.Produces;
    import jakarta.inject.Inject;
    import jakarta.inject.Named;
    
    @ApplicationScoped
    public class SoapClientResource extends RouteBuilder {
    
        @Inject
        SoapClientConfiguration configuration;
    
        @Override
        public void configure() throws Exception {
            rest()
                .post("/add")
                .routeId("RouteRest")
                .consumes("application/json")
                .produces("application/json")
                .to("direct:consumeSoapService");
    
            from("direct:consumeSoapService")
                .routeId("RouteSoap") 
                .setBody(constant(new Object[] {10, 20}))
                .log("[REQUEST] Received POST with parameters: [ ${body[0]} - ${body[1]} ]")
    
                .setHeader(CxfConstants.OPERATION_NAME, constant(configuration.operationName()))
                .setHeader(CxfConstants.OPERATION_NAMESPACE, constant(configuration.operationNamespace()))
                
                .to("cxf:bean:calculatorSoapEndpoint?dataFormat=POJO")
                .log("[RESPONSE] Received POST with parameters: ${body}");
        }       
    
        @Produces
        @SessionScoped
        @Named("calculatorSoapEndpoint")
        CxfEndpoint calculatorSoapEndpoint() throws Exception {
            final CxfEndpoint result = new CxfEndpoint();
            result.setServiceClass(CalculatorSoap.class);       
            result.setAddress(configuration.operationAddress());
            result.setWsdlURL(configuration.operationWsdlURL());     
            return result;
        }
    }

    Run the following command to consume a REST service that internally calls the SOAP service:

    curl -s -X POST 'http://localhost:8080/add' --header 'Content-Type: application/json'

    We review the logs:

    INFO  [RouteSoap] (vert.x-worker-thread-1) [REQUEST] Received POST with parameters: [ 10 - 20 ]
    INFO  [RouteSoap] (default-workqueue-1) [RESPONSE] Received POST with parameters: 30

    To facilitate JSON serialization and deserialization, add the camel-quarkus-jackson dependency.

    mvn quarkus:add-extension -Dextension=org.apache.camel.quarkus:camel-quarkus-jackson

    Create the RequestSoapDao.java class to perform mapping of the fields that will be used as the request body.

    package com.redhat.quarkus.platform;
    
    import io.quarkus.runtime.annotations.RegisterForReflection;
    
    @RegisterForReflection
    public class RequestSoapDao {
    
        public int param1;
        public int param2;
    
        public Object[] getOperation() {
            return new Object[]{param1, param2};
        }  
    }

    Update the configure() method to receive a JSON and convert it into a POJO using the RequestSoapDao.java class. Respond with a JSON containing the sum of the values.

    ...output omitted...
    @Override
    public void configure() throws Exception {
        rest()
            .post("/add")
            .routeId("RouteRest")
            .consumes("application/json")
            .produces("application/json")
            .to("direct:consumeSoapService");
    
        from("direct:consumeSoapService")
            .routeId("RouteSoap") 
            //.setBody(constant(new Object[] {10, 20}))
            .log("[REQUEST] Received POST with parameters: ${body}")
    
            .unmarshal().json(JsonLibrary.Jackson, RequestSoapDao.class)
            .log("[REQUEST] Data transformation: ${body}")
            .setBody(simple("${body.getOperation}"))    
    
            .setHeader(CxfConstants.OPERATION_NAME, constant(configuration.operationName()))
            .setHeader(CxfConstants.OPERATION_NAMESPACE, constant(configuration.operationNamespace()))
            
            .to("cxf:bean:calculatorSoapEndpoint?dataFormat=POJO")
            .log("[RESPONSE] Received POST with parameters: ${body}")
    
            .convertBodyTo(String.class)
            .marshal().json(JsonLibrary.Jackson)
            .setBody(simple("{\"message\":${body}}"))
            .log("[RESPONSE] Data transformation: ${body}"); 
    }
    ...output omitted...

    Run the following command to consume the REST service that internally calls the SOAP service:

    curl -s -X POST 'http://localhost:8080/add' --header 'Content-Type: application/json' \
      --data '{"param1": 10, "param2": 20}' | jq

    The response from the service will be:

    {
      "message": "30"
    }

    We review the logs:

    INFO  [RouteSoap] (vert.x-worker-thread-1) [REQUEST] Received POST with parameters: {"param1": 10, "param2": 20}
    INFO  [RouteSoap] (vert.x-worker-thread-1) [REQUEST] Data transformation: com.redhat.quarkus.platform.RequestSoapDao@bbd0b26
    INFO  [RouteSoap] (default-workqueue-1) [RESPONSE] Received POST with parameters: 30
    INFO  [RouteSoap] (default-workqueue-1) [RESPONSE] Data transformation: {"message":"30"}

    Conclusion

    Configuring SOAP web services with Apache Camel on Quarkus offers a robust and efficient solution for integrating services into modern applications. Through the practices shared in this article, developers can effectively create Quarkus projects, consume SOAP services easily, and expose RESTful endpoints agilely. The combination of Apache Camel and Quarkus provides a versatile platform for building scalable and flexible applications. With integrated management of JSON data serialization and deserialization, developers can build comprehensive solutions that meet the needs of their projects.

     

    Related Posts

    • Using GeoJSON with Apache Camel K for spatial data transformation

    • Add Java language support for Apache Camel K inside Eclipse Che

    • How to configure SOAP web services with Apache Camel

    • How to migrate your SOAP web service to REST with Camel

    • Quarkus for Spring developers: Getting started

    • Migrating from Red Hat Fuse to Red Hat build of Apache Camel

    Recent Posts

    • Red Hat UBI 8 builders have been promoted to the Paketo Buildpacks organization

    • Using eBPF in Red Hat products

    • How we made one data layer serve the UI, the mocks, and the E2E tests

    • Build trusted Python containers with Project Hummingbird and Calunga

    • Simplify distributed tracing: ObservabilityInstaller installation

    What’s up next?

    Learn how to optimize Java for today’s compute and runtime demands with Quarkus. Quarkus for Spring Developers introduces Quarkus to Java developers, with a special eye for helping those familiar with Spring’s conventions make a quick and easy transition.

    Get the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility