Saturday, May 01, 2010

webHttpBinding - REST in WCF (Part 3)


Now we know that using [WebGet] we can get a resource based on URI. This is just the GET verb of HTTP, we also have other Verbs – PUT,POST,DELETE. To use these verbs WCF has the [WebInvoke] attribute.

However we cannot allow anyone to PUT,POST,DELETE our resources, so we will typically have some authentication process before we can allow this. This is achieved by reading and writing to the HTTP context. It can also be used to control caching, set content type, etc.

Taking the .svc Out of REST
WCF Services hosted in IIS use the .svc extension. This does not follow common REST URI naming practices. For example, the service in Part 1 and 2 is accessed using the following URI:
http://localhost/TimeService.svc/Now?GMT=1
You can remove the .svc extension by using an ASP.NET HttpModule (with IIS 7.0 only) to call HttpContext.RewritePath to modify the URI. This would allow the URI to take the following form: http://localhost/TimeService/Now?GMT=1


Technorati Tags: ,

No comments: