Demystifying The Code

REST in WCF – Part XI (Tunneling PUT through POST)

A common scenario you may encounter when designing your RESTful services is supporting clients that only work with GET and POST.  Two such clients on our stack are Silverlight 2 and our ASP.NET AJAX Client Libraries (out of the box).  This brings about a quandary: should I design a HI-REST service interface (support GET, PUT, POST, DELETE) and not support these clients or should I design a LO-REST service interface (only support GET and POST) and support clients such as these.  Fortunately, for you, these are not the only answers to this problem. 

In this post, I will illustrate how to "tunnel" PUT, DELETE or any other HTTP Method over POST.  What I mean by tunneling over POST is that you actually use an HTTP POST, but you pass additional information that allows your call to be routed to the appropriate service operation that supports other Methods.  In this case, we will support passing the "real" method we want to call in an X-HTTP-Method-Override HTTP Header.  This would have been a chore prior to the release of the WCF REST Starter Kit.  Now, however, it is quite simple.  Let’s take a look…

[ Read More → ]

Demystifying The Code