This project demonstrates how to create a SOAP web service using Spring Boot and Apache CXF using contract-first approach. It provides a simple "Hello" service that accepts a name parameter and returns a greeting message.
-
Spring Boot 3.4.4 application with Apache CXF integration
-
JAX-WS SOAP web service implementation
-
Code generation from WSDL using CXF’s wsdl2java tool
-
Request/response logging using CXF logging interceptors
-
Undertow as the embedded web server
-
Spring Boot Actuator for health monitoring
To build the application, use Maven:
mvn clean packageThis will:
-
Generate Java classes from the WSDL definition
-
Compile the code
-
Run tests
-
Package the application into an executable JAR
You can run the application using the following command:
java -jar target/spring-boot-cxf-jaxws-xml-1.0-SNAPSHOT.jarOr using Maven:
mvn spring-boot:runOnce started, the service endpoints will be available at:
-
SOAP Web Service: http://localhost:8080/service/hello
-
WSDL Definition: http://localhost:8080/service/hello?wsdl
-
Health Endpoint: http://localhost:8081/actuator/health
You can test the service using a SOAP client like SoapUI or using curl:
curl -X POST \
-H "Content-Type: text/xml;charset=UTF-8" \
-H "SOAPAction: urn:SayHello" \
-d '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.ws.sample/">
<soapenv:Header/>
<soapenv:Body>
<ser:sayHello>
<myname>Luigi</myname>
</ser:sayHello>
</soapenv:Body>
</soapenv:Envelope>' \
http://localhost:8080/service/hello