Skip to main content
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 Red Hat 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

    • Red Hat OpenShift AI
    • 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.

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.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • 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

    • 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.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

How to configure SOAP web services with Apache Camel

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

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

  • A day in the life of an NVIDIA H100 on Red Hat OpenShift 5

  • Migrate BuildConfigs to builds for Red Hat OpenShift with one plug-in install

  • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

  • Agent harness engineering: Separating model capabilities from enforcement

  • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

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

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
Ask AI