So a couple of proposals, a presentation at a internal conference, and some work on our [long overdue] website makeover, I am ready to start playing with the WCF Web programming model some more. Two things immediately come to mind. I am going to address the first one here.
So, if you've never had the distinct pleasure of working directly with softies, you may not recognize a peculiar quirk of their culture, an "ism" if you will. That quirk is the tendency to convert verbs into nouns. So, if you are working with a client that has an incumbent non-MS infrastructure, then you are working a "compete." If you have a question or request or favor, it is often referred to as an "Ask."
SO.
This is an ASK.
I want an ognl or xpath-like syntax in uri templates to allow me to map down into object. So, instead of:
[OperationContract]
[WebInvoke(Method = "PUT", UriTemplate = "/customer/{id}" )]
void PutCustomer(int id, Customer customer );
I could instead have
[OperationContract]
[WebInvoke(Method = "PUT", UriTemplate = "/customer/{customer.id}" )]
void PutCustomer(Customer customer);
This might also be helpful when I use post to create a new customer, e.g.
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/customers" )]
[Location(UriTemplate = "/customer/{return.id}" )]
Customer CreateCustomer(Customer customer);
Note that the location header does not exist currently. It is my suggestion of how you might specify the location header when a resource has been created via POST. I threw "return" in there as a variable to reference the return value. The idea is definitely half-baked at best, but I think that, given that we're using HTTP as the contract here, and HTTP says return a location header, then it makes sense that we provide a way in the contract to handle that.
I think it would also be interesting to modify the template behavior to adopt some uri conventions codified in Sam Ruby and Leonard Richardson's new book Restful Web Services. From Udell's post:
"[use] commas to encode ordered siblings (/parent/child1,child2), and semicolons to encode unordered siblings (/parent/red;green)."
So, we could do something like GET /customers/1,2,3,4,5, and receive back the customers specified by the list, e.g.
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "/customers/{ids}" )]
List<Customer> CreateCustomer(int[] ids);
I hope that you find that useful feedback.
Recent Comments