1. What is API(Application programming interface).
Web API is an extensible framework for building HTTP based services that can be accessed in different applications on different platforms such as web, windows, mobile etc.
It is very similar to ASP.NET MVC since it contains the MVC features such as routing, controllers, action results, filter, model binders, IOC container or dependency injection.
* ASP.NET Web API is an extension of WCF REST API. In short, it is an replacement of WCF REST API.
Web API Features
Supports convention-based CRUD actions, since it works with HTTP verbs GET,POST,PUT and DELETE.
Responses have an Accept header and HTTP status code.
Supports multiple text formats like XML, JSON etc. or you can use your custom MediaTypeFormatter.
May accepts and generates the content which may not be object oriented like images, PDF files etc.
Automatic support for OData. Hence by placing the new [Queryable] attribute on a controller method that returns IQueryable, clients can use the method for OData query composition.
Supports Self-hosting or IIS Hosting.
Why to choose Web API?
If you need a Web Service and don’t need SOAP, then ASP.NET Web API is best choice.
Used to build simple, non-SOAP-based HTTP Services on top of existing WCF message pipeline.
Easy configuration unlike WCF REST service.
Simple service creation with Web API. With WCF REST Services, service creation is difficult.
Based on HTTP and so easy to define, expose and consume in a REST-ful way.
Based on light weight RESTful architecture and good for devices which have limited bandwidth like smart phones.
Open Source.
Difference Between SOAP And REST
SOAP
Slower due to defined specification.
Request and response format is always XML .
Requires bandwidth as the amount of data to transfer is a lot
It is a protocol that defines some specifications which are to be followed strictly
Less preferred due to its complex design
Highly secure as it has its own security.
HTTP SSL Encryption and WS-Security encryption are used to secure SOAP messages
No need of caching mechanism
Can communicate over HTTP as well as SMTP
REST
Faster as there is no defined specifications
Request and Response can be either in XM, JSON or plain text.
Can work perfect even in case of low bandwidth
Due to its architectural approach, it doesn’t have any strict specification
Easy to implement
Doesn’t have its own security. Hence depends on application defined security
Data can be secured only by HTTP SSL Encryption
Requires caching mechanism
Can communicate only over HTTP
==========================
C - Create - POST
R - Read - GET
U - Update - PUT
D - Delete - DELETE
Web API is an extensible framework for building HTTP based services that can be accessed in different applications on different platforms such as web, windows, mobile etc.
It is very similar to ASP.NET MVC since it contains the MVC features such as routing, controllers, action results, filter, model binders, IOC container or dependency injection.
* ASP.NET Web API is an extension of WCF REST API. In short, it is an replacement of WCF REST API.
Web API Features
Supports convention-based CRUD actions, since it works with HTTP verbs GET,POST,PUT and DELETE.
Responses have an Accept header and HTTP status code.
Supports multiple text formats like XML, JSON etc. or you can use your custom MediaTypeFormatter.
May accepts and generates the content which may not be object oriented like images, PDF files etc.
Automatic support for OData. Hence by placing the new [Queryable] attribute on a controller method that returns IQueryable, clients can use the method for OData query composition.
Supports Self-hosting or IIS Hosting.
Why to choose Web API?
If you need a Web Service and don’t need SOAP, then ASP.NET Web API is best choice.
Used to build simple, non-SOAP-based HTTP Services on top of existing WCF message pipeline.
Easy configuration unlike WCF REST service.
Simple service creation with Web API. With WCF REST Services, service creation is difficult.
Based on HTTP and so easy to define, expose and consume in a REST-ful way.
Based on light weight RESTful architecture and good for devices which have limited bandwidth like smart phones.
Open Source.
Difference Between SOAP And REST
SOAP
Slower due to defined specification.
Request and response format is always XML .
Requires bandwidth as the amount of data to transfer is a lot
It is a protocol that defines some specifications which are to be followed strictly
Less preferred due to its complex design
Highly secure as it has its own security.
HTTP SSL Encryption and WS-Security encryption are used to secure SOAP messages
No need of caching mechanism
Can communicate over HTTP as well as SMTP
REST
Faster as there is no defined specifications
Request and Response can be either in XM, JSON or plain text.
Can work perfect even in case of low bandwidth
Due to its architectural approach, it doesn’t have any strict specification
Easy to implement
Doesn’t have its own security. Hence depends on application defined security
Data can be secured only by HTTP SSL Encryption
Requires caching mechanism
Can communicate only over HTTP
==========================
C - Create - POST
R - Read - GET
U - Update - PUT
D - Delete - DELETE
No comments:
Post a Comment