Last post Nov 26, 2008 04:51 PM by aramana
Nov 25, 2008 11:09 PM|tongc|LINK
There are several templates shipped with the new REST Starter kit, however there's no good descrition of them anywhere that i could find. I look at the release notes as well and coulnd't find when to use what? Is there any docco somewhere that anyone can
refer me to? When should i use, RES singleton, collection, atom, atom feed service or just plan xml?
Nov 25, 2008 11:13 PM|tongc|LINK
Found the solution 5 seconds after i posted the question [8-)] ... it was opened in one of my 50 firefox tabs lol...
The WCF REST Starter Kit CTP contains Visual Studio project templates and item templates to guide users on how to build RESTful services using WCF. You can create new projects or include the service as an item in, say, an ASP .NET website from Visual Studio
The Atom Feed Service template allows users to create a service that returns a collection as a feed in the Atom Syndication Format. See the
The Resource singleton service template allows users to create a service that represents a single instance of a resource, and expose it as XML or JSON. See the
Counter sample, which shows how to have a single instance of a counter that clients can change in a RESTful way.
The Resource Collection service template allows users to create a service that represents a collection of resources exposed as XML or JSON. See the
Tasks Collection sample.
The Atom Publishing Protocol service template allows users to create a service that manages a collection of resources using the Atom Publishing Protocol. The service allows users to get a Service Document that represents the types of collections managed
by the service, as well as what content types it supports and other information. The user then uses HTTP verbs like GET, PUT, POST and DELETE to manage the items in the collection. The collection is returned as an Atom feed. Each collection can contain a single
type of content (say jpeg images) or multiple content types. You can also set the size of each page to be returned in the feed easily within the template. See the
AtomPub Task Service sample for an example that manages a collection of tasks over Atom Publishing Protocol.
Many services that leverage http extensively also use the URL to specify an action that gets implemented in the service. For instance, a picture feed service can have a searchPictures query to find pictures by a keyword. This is enabled by the Http Plain
XML service template. See the TasksService template for an example.
Nov 25, 2008 11:17 PM|tongc|LINK
I am still confused why there are Singleton template and Collection tempalte ... [8-|] why can't just have one template called WCF Rest service
Nov 25, 2008 11:48 PM|tongc|LINK
part of my confusion is addressed here http://codeidol.com/csharp/wcf/Instance-Management/Singleton-Service/
to quote from the above article
The singleton service is the ultimate sharable service. When a service is configured as a
clients independently get connected to the same
single well-known instance, regardless of which endpoint of the service they connect to. The singleton service lives forever and is only disposed of once the
host shuts down. The singleton is created exactly once, when the host is created.
Using a singleton does not
require the clients to maintain a session with the singleton instance, or to use a binding that
supports a transport-level session. If the contract the client
consumes has a session, then during the call the singleton will have the same session ID as the client (binding permitting), but closing the client proxy will only terminate the session, not the singleton instance. In addition, the session will never expire.
If the singleton service supports contracts without a session, those contracts will not be per-call: they too will be connected to the same instance. By its very nature, the singleton is shared, and each client should simply create its own proxies to it.
Nov 26, 2008 04:51 PM|aramana|LINK
A singleton is used when you want a single instance of the service to respond to all calls - when different calls, potentially from multiple users update the resource, say, by calling PUT, the same instance is updated. A collection, on the other hand is
used to handle any collection of objects - for example, if you want a service that manages a collection of tasks, you could use the resource collection template to implement that service. In this case, you can post new tasks to the collection by calling POST
on the collection URL. See the Tasks Collection sample for details.
Hope that helps,
Senior Program Manager
WCF REST team