WCF? don't think so...
i did a bit of digging into WCF this week. i was looking into the details of the UriTemplate
services provided by WCF. looking for ideas on how to improve my UriPattern
support in exyus. didn't really find much, tho.
i also got a chance to peruse the 'REST support' in WCF - not so much. here's a simple example on the MSDN site:
[ServiceContract] interface ICustomer { //"View It" [OperationContract] [WebGet] Customer GetCustomer(): //"Do It" [OperationContract] [WebInvoke] Customer UpdateCustomerName( string id, string newName ); }
The preceding code allows you to make the following HTTP requests.
GET /GetCustomer
POST /UpdateCustomerName
nope. not liking it at all. really kinda disappointed, too. i still think my approach is better:
// example handler for a product category resource [UriPattern(@"/data/products/(?<pid>[^/?.]*)(.*)?")] [MediaTypes("text/html", "text/xml")] public class productsResource : XmlFileResource { public productsResource() { this.ContentType = "text/html"; this.AllowPost = false; this.AllowDelete = true; this.AllowCreateOnPut = true; this.DocumentsFolder = "~/documents/products/"; this.StorageFolder = "~/storage/products/"; this.LocalMaxAge = 600; this.ImmediateCacheUriTemplates = new string[] { "/data/products/", "/data/products/{pid}" }; } }
the above (along with some XSL/XSD documents to handle some details) is all you need to support the following operations:
GET /data/products/
GET /data/products/{pid}
PUT /data/products/{pid}
DELETE /data/products/{pid}
the above code automatically handles caching of GET
operations; properly supports ETags
to ensure there is no Lost Update problems when editing existing resources; and even supports multiple media types for the same resource.
i've spent several months tweaking my exyus engine and, based on what i'm seeing and hearing, i think it's about ready to see the light of day!