Sunday, April 18, 2010

webHttpBinding – REST in WCF (Part 1)


REST stands for Representational State Transfer

It basically means exposing services

  • based on URI
  • encode message without the overhead of SOAP
  • pass parameter using HTTP
  • format data using JSON or POX

Service Contract

Get the complete code solution from this SVN url : http://subversion.assembla.com/svn/TechnologyAndMe/RestTimeService

using System.ServiceModel;
using System.ServiceModel.Web;

[ServiceContract]
public interface ITimeService
{
[OperationContract]
[WebGet]
string Now(string GMT);
}


Web.Config





behaviorConfiguration="webBehavior">

















Now to access the service hit the service with this url

http://localhost:3048/TimeService.svc/Now?GMT=1


The output is as follows


GMT 14/18/2010 23:23:58

No comments: