Hecklers in Development
Code, coffee, & camaraderie. Collection, unordered. ;)
Many of us use JSON almost exclusively now, which is generally a good thing. But what happens when you need to “speak XML” with your Spring Boot REST endpoints?

 

XML support in Spring Boot’s REST endpoints is not enabled by default, but adding it isn’t difficult at all. Simply add the following dependency to your POM (or similar entry to your Gradle build file, if that’s the way you roll) and rebuild:

 

 

Now, to test our results. To do so, I’m using the excellent httpie, with its shortcut that allows the omission of the hostname for localhost.

 

JSON

 

XML

 

 

Note that no changes are required to your code, as Spring Boot assesses your classpath and adds XML support via auto-configuration. Simple and painless! 🙂

 

Thanks for reading, be sure to follow me on Twitter for future tips!

 

Keep coding,
Mark
Share

Related Posts:


Tags: , , , , , , , , , ,

Powered by Wordpress
Theme © 2005 - 2009 FrederikM.de, heavily modified by Mark Heckler
BlueMod is a modification of the blueblog_DE Theme by Oliver Wunder