CREATE REST SERVICE USING WCF

Опубликовано: 29 Октябрь 2024
на канале: Syed Ali
154
2

CREATE REST SERVICE USING WCF:
WCF (Windows Communication Foundation) is a secure, reliable, and scalable messaging platform that can be used to build Web services in .Net.
It provides a unified programming model for developing service oriented applications.
You can use WCF to build RESTful services in .NET.
REST (Representational State Transfer) is an architecture paradigm that conforms to the REST architecture principles.
The REST architecture is based on the concept of resources:
It uses resources to represent the state and functionality of an application. These resources are in turn identified using URIs over the HTTP protocol.


Implementing the RESTful WCF Service
Working with WCF, you need to create a service contract
and then define the service operations or operation contracts in it.
A WCF service comprises of the following:
1. Service class
2. Service contract
3. One or more operation contracts
4. One or more endpoints
5. Hosting environment



A Service Contract is used to specify the operations that are available for the service client to consume.

A Data Contract is used to describe the data that needs to be exchanged between the service provider and the service consumer

public class Product
{
[DataMember]
public Int32 id { get; set; }
[DataMember]
public string Name { get; set; }
}