I’m very new to REST. As far as I know, I could use an ordinary Servlet to return the following JSON text:
{ "firstName":"John" , "lastName":"Doe" }
and thus call that a REST based Web service. So, the question is why do we use a Web Service Frameworks Such as CXF to create REST based Web services? Is using a framework simply for convenience or there is much more than convenience?
Because the framework automates a lot of the gluing code that connects between the level of the webapp and the level of your methods. You get to avoid writing the code that does the dispatch to different methods, and you leverage the deserialization and serialization engines that the framework understands. What’s more, you get to do this declaratively through things like annotations; that’s just so much easier to get right than doing it all by hand. This advantage becomes much stronger as the complexity of the webapp increases; while there’s not much benefit for a single resource with only one representation, with a nested collection of 20–30 resources each with many representations and supported methods, stitching it all together by hand is a complete PITA and a framework helps a lot.
In short, frameworks just let you avoid writing lots of boring code that is simultaneously difficult. You don’t need to use them, and should only in fact use them if they’re being helpful as they do restrict overall flexibility a bit, but within their domain they help hugely.