Sankar M
Sankar M

Reputation: 4789

C# SOAP vs RESTful service

How to do i create a Restful service in c#.

I have Google'd a lot and i came to know that soap is heavy weight and REST is light weight

please do share what makes them light weight and heavy weight.

Also i need a sample of a same service in SOAP and Restful service.

thanks in advance.

Upvotes: 3

Views: 3662

Answers (1)

Alex
Alex

Reputation: 8937

SOAP - is a SOA standard for exchanging messages between different environments. All messages have the same structure which in its basic view represends an envelop which contains of header and a body. The header usually carries the decriptional information, such as name of calling method for example. The body is usually used to carry the data itself, which could be the arguments of executing method. Example of SOAP message:

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Header>
  </soap:Header>
  <soap:Body>
    <m:GetStockPrice xmlns:m="http://www.example.org/stock">
      <m:StockName>IBM</m:StockName>
    </m:GetStockPrice>
  </soap:Body>
</soap:Envelope>

REST - is another standard for exchanging messages, which is based on HTTP web methods (GET, POST, DELETE, PUT and HEAD). It is light weight, because it does not contains the envelop components. Usually it has only clear data, like this:

 <GetStockPrice>
      <StockName>IBM</StockName>
 <GetStockPrice>

The main advatage of SOAP over REST, that it is protocol independant and can be used over TCP, SMTP, MQ.

There is a nice Step-by-Step FAQ of creating REST services on this link: http://www.codeproject.com/Articles/105273/Create-RESTful-WCF-Service-API-Step-By-Step-Guide

Upvotes: 5

Related Questions