Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

How to configure SOAP web services with Apache Camel

March 28, 2023
Michael Thirion
Related topics:
JavaQuarkusSecurity
Related products:
Red Hat build of Quarkus

Share:

This article demonstrates how to configure Simple Object Access Protocol (SOAP) web services with the Red Hat build of Apache Camel, Quarkus version. In Apache Camel version 3, the support for the SOAP protocol is still provided by the CXF framework. Therefore, on Quarkus, we will be relying on the camel-quarkus-cxf-soap extension.

A common REST to SOAP transformation use case

With the CXF runtime, there is a distinction to make between a SOAP service and the client of a SOAP service.

Let's use a very common use case to demonstrate those two parts distinctively. Let's imagine a legacy SOAP web service backend that we want to expose behind a REST endpoint (Figure 1).

Use case architecture.
Figure 1. Use case architecture.

You can find the source code of the two applications developed for that purpose on this GitHub page.

The SOAP web service backend is represented by a mock implementation of a publicly available definition, sourced from herongyang.com. The web service at play is Registration SOAP 1.1.

For both the CXF client and server development, the first step is to generate the Java objects corresponding to the WSDL elements. This can be done with the cxf-codegen-plugin Maven plugin, whose wsdl2java task generates Java representations of the soap request and response payloads, as well as the service interface and its implementation (PortType).

$ tree target/generated-sources/cxf
target/generated-sources/cxf
└── https
    └── www_herongyang_com
        └── service
            ├── ObjectFactory.java
            ├── package-info.java
            ├── RegistrationPortType.java
            ├── RegistrationRequest.java
            ├── RegistrationResponse.java
            └── RegistrationService.java

Configuring a Camel CXF SOAP server

Let's now dig into the core part of the configuration.

On the server side, there is a Camel route that starts with the following line:

from("cxf:registration?serviceClass=https.www_herongyang_com.service.RegistrationPortType")

The second element of the endpoint URI is the name of a CxfEndpoint Java bean that contains the configuration of the CXF endpoint such as the service name, endpoint name, and exposed URL.

@Named("registration")
@ApplicationScoped
public class SoapServiceBean extends CxfEndpoint {

    public SoapServiceBean() {
        super();

        try {
            this.configure();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

    }

    private void configure() throws ClassNotFoundException {

       QName serviceQname = new QName("https://www.herongyang.com/Service/", "registrationService");    // From WSDL :: <wsdl:service name="registrationService">
       this.setServiceNameAsQName(serviceQname);

       QName endpointQname = new QName("https://www.herongyang.com/Service/", "registrationPort");    // From WSDL :: <wsdl:port name="registrationPort">
       this.setEndpointNameAsQName(endpointQname);

       this.setAddress("http://localhost:8055/soap/registration");                    // Exposed address with the /soap root context defined in application.properties

    }
}

That's it!

With that configuration, the web service should be available at http://localhost:8085/soap/registration. We can test it with SOAPUI using the following request:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="https://www.herongyang.com/Service/">  
<<soap:Header/>>  
   <<soap:Body>>  
      <ser:RegistrationRequest date="now" event="123">
         <Guest>John</Guest>
      </ser:RegistrationRequest>
   </soap:Body>  
</soap:Envelope>

Configuring a Camel CXF SOAP client

In the case of a client, the CxfEndpoint bean is not required. The URI can directly embed the target address as follows:

 .to("cxf:http://localhost:8055/soap/registration?serviceClass=https.www_herongyang_com.service.RegistrationPortType")

You can attempt an end-to-end test with the following command:

curl -H "Content-Type: application/json" -XPOST http://localhost:8050/api/registration -d '{"event":"123","guest":"john"}'

Applying WS-Security or other SOAP features

The CXF framework still builds on the concept of interceptors and interceptors chain. On Quarkus, interceptors are injected into the CXF runtime in Java.  The hook to the CXF runtime is the cxfConfigurer option of the URI endpoint.

For the server, the endpoint URI becomes:

from("cxf:registration?serviceClass=https.www_herongyang_com.service.RegistrationPortType&cxfConfigurer=#mywssecurity")

On the other hand, for the client, it becomes:

to("cxf:http://localhost:8055/soap/registration?serviceClass=https.www_herongyang_com.service.RegistrationPortType&cxfConfigurer=#mywssecurity")

On both lines, the mywssecurity element is a reference to a Java bean that implements the CxfConfigurer interface. This interface has methods to configure either the CXF server, client, or both. Thus, in our case, on the client side, we have:

@Named("mywssecurity")
@ApplicationScoped
public class WSServiceBean implements CxfConfigurer {

    @Inject
    @ConfigProperty (name = "app.webservice.soap.wssecurity.user")        // custom property defined in application.properties
    private String user;

    @Inject
    @ConfigProperty (name = "app.webservice.soap.wssecurity.mustunderstand")    // custom property defined in application.properties
    private String mustunderstand;

    public WSServiceBean() {
        super();
    }


    @Override
    public void configure(AbstractWSDLBasedEndpointFactory factoryBean) {
        // TODO Auto-generated method stub
        //throw new UnsupportedOperationException("Unimplemented method 'configure'");
    }

    @Override
    public void configureClient(Client client) {

        Map<String,Object> wsproperties = new HashMap<String, Object>();
        wsproperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.USERNAME_TOKEN_NO_PASSWORD);
        wsproperties.put(ConfigurationConstants.ALLOW_USERNAMETOKEN_NOPASSWORD, "true");
        wsproperties.put(ConfigurationConstants.USER, user);
        wsproperties.put(ConfigurationConstants.MUST_UNDERSTAND, mustunderstand);
        WSS4JOutInterceptor wssecurity = new WSS4JOutInterceptor(wsproperties);

        client.getOutInterceptors().add(wssecurity);

        //throw new UnsupportedOperationException("Unimplemented method 'configureClient'");
    }

    @Override
    public void configureServer(Server server) {
        // TODO Auto-generated method stub
        //throw new UnsupportedOperationException("Unimplemented method 'configureServer'");
    }
}

While on the server side, we have the following:

@Named("mywssecurity")
@ApplicationScoped
public class WSServiceBean implements CxfConfigurer {

    @Inject
    @ConfigProperty (name = "app.webservice.soap.wssecurity.user")        // custom property defined in application.properties
    private String user;

    public WSServiceBean() {
        super();
    }


    @Override
    public void configure(AbstractWSDLBasedEndpointFactory factoryBean) {
        // TODO Auto-generated method stub
        //throw new UnsupportedOperationException("Unimplemented method 'configure'");
    }

    @Override
    public void configureClient(Client client) {
        // TODO Auto-generated method stub
        //throw new UnsupportedOperationException("Unimplemented method 'configureClient'");
    }

    @Override
    public void configureServer(Server server) {

        Map<String,Object> wsproperties = new HashMap<String, Object>();
        wsproperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.USERNAME_TOKEN_NO_PASSWORD);
        wsproperties.put(ConfigurationConstants.ALLOW_USERNAMETOKEN_NOPASSWORD, "true");
        wsproperties.put(ConfigurationConstants.USER, user);
        WSS4JInInterceptor wssecurity = new WSS4JInInterceptor(wsproperties);

        server.getEndpoint().getInInterceptors().add(wssecurity);

        //throw new UnsupportedOperationException("Unimplemented method 'configureClient'");
    }
}

Summary

This article demonstrates how to configure SOAP web services with the Red Hat build of Apache Camel, Quarkus version. If you have questions, feel free to comment below. We welcome your feedback!

Last updated: August 14, 2023

Related Posts

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

  • How I built a serverless blog search with Java, Quarkus, and AWS Lambda

  • Quarked testing: Writing tests for Quarkus

  • Sending a telegram with Apache Camel K and Visual Studio Code

Recent Posts

  • How to enable Ansible Lightspeed intelligent assistant

  • Why some agentic AI developers are moving code from Python to Rust

  • Confidential VMs: The core of confidential containers

  • Benchmarking with GuideLLM in air-gapped OpenShift clusters

  • Run Qwen3-Next on vLLM with Red Hat AI: A step-by-step guide

What’s up next?

Quarkus for Spring Developers

Quarkus for Spring Developers introduces Quarkus to Java developers, 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

Products

  • Red Hat Enterprise Linux
  • Red Hat OpenShift
  • Red Hat Ansible Automation Platform

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
© 2025 Red Hat

Red Hat legal and privacy links

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

Report a website issue