O'Reilly logo

ASP.NET Web API by Joydip Kanjilal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making the service RESTful

To make the SecurityService RESTful, you would need to specify the [WebGet] or [WebInvoke] attributes in your service contract. Although the former indicates that the WCF Service can respond to HTTP Get requests, the latter is used to indicate that the WCF Service can respond to HTTP Post requests. Both belong to the System.ServiceModel.Web namespace, and are actually part of the HTTP programming model for WCF.

The following code snippet illustrates how a typical [WebGet] attribute is defined:

[WebGet(UriTemplate = 
"/sales/getsales.xml",
  BodyStyle = WebMessageBodyStyle.Bare,
  RequestFormat = WebMessageFormat.Xml,
  ResponseFormat = WebMessageFormat.Xml)]

The [WebInvoke] attribute can be defined so that your WCF Service can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required