Is it possible to send json and receive json using spring webservices?
Thanks Damien
The class App implements CommandLineRunner and calls the SpringApplication. run() method by passing this instance of class App. class. This will, in turn, call the run method, where we have code to call a RESTful Web Service and consume JSON response using RestTemplate class of Spring framework.
Web services based on REST Architecture are known as RESTful web services. These webservices uses HTTP methods to implement the concept of REST architecture. A RESTful web service usually defines a URI, Uniform Resource Identifier a service, provides resource representation such as JSON and set of HTTP Methods.
The same resource may return either XML or JSON depending upon the request, but it shouldn't return both at the same time. You will know which one to return based upon the request, so there is no need to generate both -- just generate the one you'll be returning.
You can use RESTEasy for it. It is easily pluggable into Spring and has better JSON support than many RPC style Web Service frameworks.
And here is a guide to get it working with Spring.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With