Monday, January 28, 2008

Sud-less Web Services

Remember the no-more-tears baby shampoo? This article is actually the equivalent for web services in ASP.NET. Standard ASP.NET web services convert their return types into SOAP objects thus making them a bit painful for developers from other platforms to work with. To go the way of the crowd making the paradigm shift toward RESTful interfaces, you can get your web services to return plain ol' XML by simply specifying the return type of your method to an XmlDocument. I know, it seems like that little trick you were always looking for. Now, the next part of it is to enable the Get protocol for the web services which is easily added to the webServices-protocols section of the web.config file using Visual Studio Intellisense.

And there you go - you can now code regular RESTful web services in ASP.NET. The downside is that you have to manually build an XmlDocument object in each method but that's easily abstracted by writing a couple of helper classes.

No comments: