Scott Hanselman

Basically I want something like the following to work public class BookService RestService RestMet

November 12, 2002 Comment on this post [0] Posted in Web Services | XML
Sponsored By

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. 

[News from the Forest]

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.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

GarySPAN

November 12, 2002 Comment on this post [0] Posted in Musings
Sponsored By

Gary Klimowicz’s First Law of Organizational Development

Most business meetings do not progress beyond the average High School Student Council meeting.

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.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

The Everett Visual CNET features Sam Gentiles got t

November 11, 2002 Comment on this post [0] Posted in Web Services
Sponsored By

The Everett Visual C++.NET features. Sam Gentile's got the scoop on the Everett release updates to VC++, which he lists as:

-98% ANSI/ISO Compliance
-Forms Designer for Managed C++
-Security Features
-Optimizer Improvements particuarly in floating point

He's got the details. Check it out. [sellsbrothers.com: Windows Developer News]

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.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

Ill be speaking at ReadySetVisual StudioNET in Portland and Seat

November 08, 2002 Comment on this post [0] Posted in Web Services | Speaking
Sponsored By

I'll be speaking at Ready...Set...Visual Studio.NET in Portland and Seattle with Chris Sells, Bill Vaughn, Chris Kinsman, and Microsoft's Jim Blizzard in Seattle on Dec 4 and Portland on Dec 11.  The PDF invite is up, please join us if you're in town!

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.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

ReSTNET Yesterday and this afternoon

November 01, 2002 Comment on this post [0] Posted in Web Services
Sponsored By

ReST.NET.

Yesterday (and this afternoon), I banged out some code that makes implementing RESTful web services a bit simpler (not too much right now). Basically using a pattern, it will dispatch a specific URI to a specific method. This pattern is of course a regular expression. Each verb may have 1 or more patterns. If you don't want to handle a specific verb, don't put it in the verbs section of the config file. When faced with this situation the handler will return Method Not Allowed to the client. [News from the Forest]

Muy interesante...

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.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.