Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

REST AND WCF


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 athono   Members   -  Reputation: 129

Like
0Likes
Like

Posted 16 July 2012 - 12:38 AM

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?

Sponsor:

#2 Cygon   Members   -  Reputation: 922

Like
0Likes
Like

Posted 16 July 2012 - 03:15 PM

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.
Professional C++ and .NET developer trying to break into indie game development.
Follow my progress: http://blog.nuclex-games.com/ or Twitter - Topics: Ogre3D, Blender, game architecture tips & code snippets.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS