| id | java-spring-boot-xml | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| title | Sample REST API with Spring-Boot and XML | ||||||||
| sidebar_label | XML API App | ||||||||
| description | This CRUD Application demonstrates REST API endpoints that serve XML responses using Spring Boot. | ||||||||
| tags |
|
||||||||
| keyword |
|
🌟 Explore creating REST APIs with XML responses using Spring-Boot. Discover the ease of integrating XML serialization through JAXB. Let's dive right in! 🚀
git clone https://github.com/keploy/samples-java.git
cd spring-boot-xml/naive-spring-boot
mvn clean installStart the Spring Boot application with:
mvn spring-boot:runNote: For Windows users, commands remain the same.
- Endpoint:
GET /api/user
Make a request using curl:
curl -X GET -H \"Accept: application/xml\" http://localhost:8080/api/user<User>
<name>John Doe</name>
<age>30</age>
<phone>0101233333</phone>
</User>Harness Keploy's test generation capabilities easily:
curl --silent -O -L https://keploy.io/install.sh && source install.shor
curl --silent -O -L https://keploy.io/ent/install.sh && source install.shkeploy record -c "java -jar target/XML-0.0.1-SNAPSHOT.jar"Start recording interactions by running:
keploy record -c "java -jar target/XML-0.0.1-SNAPSHOT.jar"Then, invoke the API using curl or your favorite API testing tool.
Execute recorded tests:
keploy test -c "java -jar target/XML-0.0.1-SNAPSHOT.jar" --delay 10Review generated test reports in Keploy/reports.
If you encounter failing tests due to variable or irrelevant data, like timestamps or dynamically generated fields, you can add them to the global noise configuration in your keploy.yml:
Example:
globalNoise:
global:
header.Date: []
body:
# To ignore some values for a field, pass regex patterns to the corresponding array value
UserList: []After updating keploy.yml with the above configuration, rerun your tests, and the issue should be resolved.
- Spring Boot
- Spring Web
- JAXB (XML serialization)
Fantastic! You've successfully navigated creating and testing XML APIs with Spring Boot and Keploy. Keep exploring, experimenting, and innovating! If you have any queries, we're here to help!
import GetSupport from '../concepts/support.md'