SOAP Webservices using Apache Camel, Springboot and CXF

Mouli Shanmuhavelu
3 min readApr 27, 2020

--

Introduction

In this article, we will see how to write a common implementation for a SOAP service which can be accessed by both HTTP and JMS endpoints.
We will be using Apache Camel, CXF and Springboot frameworks for this implementation.

As I do not see many reference for IBM MQ integration, I have integrated with IBM MQ message broker in this sample implementation. You can also integrate with any other message brokers like ActiveMQ or RabbitMQ by adding its dependencies to the project.

It is required to know the basics of Apache Camel, CXF and Springboot to continue with this article. You can find the complete source code of the application in github given in Summary section.

Apache Camel

Apache camel is a powerful opensource integration framework to efficiently integrate with various systems to exchange messages.

Apache CXF

Apache CXF is an open source services framework. It helps you build and develop services using APIs like JAX-WS and JAX-RS. These services can speak a variety of protocols such as SOAP, XML/HTTP, RESTful HTTP, or CORBA and work over a variety of transports such as HTTP, JMS or JBI.

Springboot

Springboot provides auto-configuration for Apache Camel. Auto-configuration of CamelContext auto-detects the Camel routes available in Spring context and registers the key Camel utilities.

Application overview

In this sample application, we will write a SOAP service which will get the employee id in the request and returns the corresponding employee details in response.
It is configured with both the HTTP and JMS endpoints. You can send a SOAP request through Http or JMS endpoint and the response will be returned to the same endpoint. We will use the tomcat embedded container of the Springboot to implement Http endpoint.

Application Structure

The overall structure of the application is depicted in the picture below:

wsdl

The wsdl definition of the service to fetch the EmployeeDetails is given here. It contains the definition of Request object and Response object.

soap request

GetEmployeeDetailRequest is the request object which has one field named EmployeeID in SOAP body

soap response

GetEmployeeDetailResponse is the response object which contains the fields named EmployeeID, EmployeeName and EmployeeEmail in SOAP Body.

endpoint xml

I have created a file called get-employee-detail.xml to define the endpoints for Http and JMS. Two beans with id cXFGetEmployeeDetailHttp and cXFGetEmployeeDetailWmq0 will be created which will be used by Apache Camel to consume the messages.

I have also provided some interceptors to print the exact soap request and soap response messages for debugging purpose.

xsd validation

By setting the cxf property schema-validation-enabled to true, we make use of xsd validation by CXF.

Summary

We have seen a sample implementation of SOAP web services using all open source technologies. This application can be deployed as a standalone application with embedded tomcat. It can also deployed in JBoss, Websphere or Weblogic servers.

The source code of the application is here in Github

--

--