Creating the RESTful service
Now we have the solution ready and have hosted the service in IIS. Next, we will modify the existing NorthwindService
to be RESTful. We will modify the service contracts, service implementation, and web config file.
Defining RESTful service contracts
In the existing NorthwindService
, we have defined two operations for the service, GetProduct
and UpdateProduct
. To make them RESTful, we need to change their definitions using the following steps:
- Add a reference of
System.ServiceModel.Web
to the service project,NorthwindService
. - Open the
IProductService.cs
file in the project. - Add a
using
statement:using System.ServiceModel.Web;
- Add the following line of code before the
GetProduct
method:[WebGet (UriTemplate = "Product/{id}" ...
Get WCF Multi-layer Services Development with Entity Framework Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.