CXF SOAP Without Spring

CXF SOAP Without Spring explains about step by step details of Creating / Developing Web service using Apache CXF without any spring dependencies

Apache CXF  is a free and open source project, and a fully featured Webservice framework. It helps you building webservices using different front-end API's, like as JAX-RS and JAX-WS.

Most of the tutorial related to Apache CXF is developed using spring framework, this is because of easy integration with spring. But it is not a necessity.

In this, we are extending CXFNonSpringServlet in order to remove spring dependency.

Required Libraries

You need to download

  1. OpenJDK 8 / Corretto
  2. Eclipse 4.15
  3. CXF-3.3.6
  4. Tomcat 9

Following jar must be in ClassPath

  1. asm-7.1.jar
  2. cxf-core-3.3.6.jar
  3. cxf-rt-bindings-soap-3.3.6.jar
  4. cxf-rt-databinding-jaxb-3.3.6.jar
  5. cxf-rt-frontend-jaxws-3.3.6.jar
  6. cxf-rt-frontend-simple-3.3.6.jar
  7. cxf-rt-transports-http-3.3.6.jar
  8. cxf-rt-wsdl-3.3.6.jar
  9. httpasyncclient-4.1.4.jar
  10. httpclient-4.5.12.jar
  11. httpcore-4.4.13.jar
  12. httpcore-nio-4.4.13.jar
  13. neethi-3.1.1.jar
  14. slf4j-api-1.7.29.jar
  15. slf4j-jdk14-1.7.29.jar
  16. stax2-api-3.1.4.jar
  17. woodstox-core-5.0.3.jar
  18. wsdl4j-1.6.3.jar
  19. xmlschema-core-2.2.5.jar

CXF Without Spring

I am creating a sample web service project that pass Student object and return with some changes on that object. The service is using simple POJO (Plain Old Java Object) bean.

Firstly create a Dynamic Web Project (File->New->Dynamic Web Project) named "CXFTutorial" according to following screenshot

CXF Without Spring CXF Without Spring

Create a Student Object

package com.student;

public class Student {
private String name;
public String getName() {
return name;
public void setName(String name) { = name;

Create a Service Interface

This service interface will defines which methods of web service, to be invoked by the client

package com.student;

import javax.jws.WebService;

public interface ChangeStudentDetails {
Student changeName(Student student);

Implement the Service Interface

Here we implement the service interface created on the previous step

package com.student;

import javax.jws.WebService;

@WebService(endpointInterface = "com.student.ChangeStudentDetails")
public class ChangeStudentDetailsImpl implements ChangeStudentDetails {
public Student changeName(Student student) {
student.setName("Hello "+student.getName());
return student;

Create a SimpleCXFNonSpringServlet

Here we are using SimpleCXFNonSpringServlet class in order to add service implementation class(ChangeStudentDetailsImpl)

package com.student;

import javax.servlet.ServletConfig;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.transport.servlet.CXFNonSpringServlet;

public class SimpleCXFNonSpringServlet extends CXFNonSpringServlet {

private static final long serialVersionUID = 1L;

public void loadBus(ServletConfig servletConfig) {
    Bus bus = getBus
("/ChangeStudent", new ChangeStudentDetailsImpl());


<web-app id="WebApp_ID" version="3.0" xmlns=""

Publishing CXF Web Service

Run CXF Without Spring


You can Find all the deployed JAX-WS/JAX-RS services you need to append 'services' at the end of the URL so URL will become following


Deployed CXF Web Service

CXF Without Spring


you can also see CXF client example in order to run this service

5 Responses to "CXF SOAP Without Spring"
  1. Roman 2012-10-04 10:10:47.0
  1. admin 2012-10-05 10:10:47.0
  1. Roman 2012-10-06 10:10:47.0
  1. Roman 2012-10-07 10:10:47.0
  1. sanjeev 2012-10-08 10:10:47.0

Your email address will not be published. Required fields are marked *