Basically I want something like the following to work public class BookService RestService RestMet
Basically I want something like the following to work -
public class BookService : RestService
{
[RestMethod(Verb="POST", Uri="something")]
public XmlNode MethodOne(string uri, XmlNode input) { }
[RestMethod(Verb="GET", Pattern="/book/**")]
public XmlNode MethodTwo(string uri) { }
[RestMethod(Verb="GET", Pattern="/order/")]
public XmlNode MethodThree(string uri, NameValueCollection queryString) { }
}
So for MethodOne, only POSTs to the URI "something" will be dispatched to it. And since it has an XmlNode as a parameter, I would check the content type of the incoming request. If it is text/xml (or one of the XML variants like application/soap+xml), I will load it and pass it in.
For MethodTwo, only POSTs to the URI /book/ and all the sub-URIs underneath book will be dispatched to it. Nothing is passed in by default. That does not mean you can't get access to the information. You can get access to the stuff through the Current HttpContext or the helper properties you inherit from RestService.
Finally for MethodThree, it is similar to MethodTwo except that the parameter it takes is NameValueCollection. This is just for convenience. The framework will pass in the query string directly. If MethodThree happened to want handle a POST, then the NameValueCollection would be a combination of Form variables as well as query string. I'm debating whether or not to make that configurable through an attribute.
This will be pretty slick when Justin gets it done...I'm looking a lot into how to implement REST on .NET, as well as how a Message Broker would look for a more SOAP-y document-y world looks.
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter
Comments are closed.