Ease of development: REST vs RPC
August 19th, 2007Bill (where is that Ó key) de hÓra: “The fundamental problem here is looking for a RESTful way to do RPC/RMI, instead of redesigning the application to expose resources.”
This gets at one of my main problems with getting people to build good RESTful services: it’s a lot of work.
While OO in theory can map pretty well to REST, it takes a lot of metadata and careful thought to turn those objects into resources. Making an RPC application is much easier. This is one of the killer features of SOAP/WSDL. I can take my business service and build a web service out of it with very little effort (I assert that there are non-evil ways to do this, but thats another story). I can then be interoperating with a .NET application in just a minute or two. Or I can take a WSDL, generate a set of objects, and just write some glue code between my internal objects and the web service objects.
Building the RESTful equivalent isn’t nearly as easy IMO. (At least for Java).
I suppose there are two ways to build RESTful services. First, you can turn your interfaces/POJOs into a RESTful service. This requires you to know:
- The relationships between the objects. I.e. parent/child relationships and primary keys. This would allows basic URIs like /customers/1 or /customers/1/orders.
- How to map methods on your business interface to resources.
Given a business interface and a set of POJOs, this isn’t quite so easy. Sure, people are working on JSR 311, annotations, etc. But I would like to assert that it will still be harder than building the equivalent RESTful service. At the very least you need to add a bunch more annotations as well as design your URI structure. (JPA annotations may give us some help here in the future - @Id, @OneToMany, etc would give some of the necessary metadata - but not everyone has these annotations on their application. It also seems a little icky to retarget these for RESTful services.).
The other option would be to design your application in a RESTful manner to begin with. I’ll be honest, I don’t have a lot of experience with doing it from the start. Most applications that I encounter have some OO/DAO backend which is exposed through various frontends.
Am I wrong about all this? Should building a RESTful service be easy/easier? (Just for the record - even if it is more work, that doesn’t mean I don’t think there aren’t other more important benefits like scalability)
September 18th, 2007 at 10:58 am
Did you check out JSR 311? Brian Leonard talked about it in his blog
http://weblogs.java.net/blog/bleonard/archive/2007/07/an_introduction_1.html
There’s a bunch of links to things too.
September 18th, 2007 at 12:45 pm
Yes, I’ve used JSR 311. You still need to put more thought into though - uri templates, content types, changing your data model to be linkable, etc. Just seems like more work up front than the “just give a pojo” to the SOAP framework approach. Not saying thats a good way to do soap, but it does work for a lot of people.
November 8th, 2007 at 8:13 pm
You can buy here viagra by the cheaoest price!!!!!!!!!!! It’s a real!!!
You can try viagra and fuck you little bitch all night!!
try and you will be happy!!
December 9th, 2007 at 3:23 pm
Hi boys!ce981299113eea1678214e2a965b9a7b
February 15th, 2008 at 9:42 am
apply for exxon gas credit card
burdening,bicycling!hexagons turf fingerprint:stodgy