Jump to content
  • Advertisement
Sign in to follow this  
athono

REST AND WCF

This topic is 2342 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

As far as I can tell REST is a methodology or an archecture. Is it a real tangable thing? I mean, can you look at a back-end code and determine if it is REST or not REST? How do you communicate with a WCF RESTful service? Are all WCF services RESTful?

Share this post


Link to post
Share on other sites
Advertisement
Yes, REST is a tangible thing with a definition. That definition has been stretched by various web service makers all wanting to give themselves the "we do REST" badge, however. I really like Boris Lublinsky attempt to reign in the chaos this has created. He defined 3 levels of REST support: Three Levels of the REST Maturity Model.

  • Level 1 means your service uses meaningful URLs to access and update resources. WCF can do that via the UriTemplate parameter in its WebGetAttribue and WebInvokeAttribute. For example, http://example.com/item/123 instead of http://example.com/myservice.svc [+parameters in SOAP message sent via POST].

    • Level 2 means you make proper use of HTTP verbs (whenever you load a page, your browsers uses HTTP GET, but HTTP has more commands: PUT, DELETE, POST). WCF can do that, too, with some effort and you may need to tweak your IIS configuration to forward these HTTP verbs to WCF correctly (so HTTP GET http://www.example.com/item/123 would send you item 123. HTTP DELETE http://www.example.com/item123 would delete item 123)

      • Level 3 means that resources returned by a web service are self-contained. The client will not need to concatenate strings and use special knowledge to build a URL for performs a specific command. So the data returned by HTTP GET http://www.example.com/item would contain the complete urls you would use to view each item in the list instead of just the item ids.

        Nearly no WCF services out there in the wild are RESTful. The reason is that WCF was designed before REST became hip and then they attempted to glue REST on top of it. It requires effort to make a WCF web service RESTful.

        You can see if a WCF service is restful either by figuring out in which form requests are passed to the service. See my descriptions above, if they use friendly URLs, respond differently to HTTP verbs and return full URLs to the web service it's REST.

        In case you are pondering to write a RESTful web service in .NET, I would recommend ServiceStack instead.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!