oDATA Vs SOAP
A comparison between oDATA and SOAP
oData |
SOAP |
Resource Based:Customer, Product, Purchase Order or Sales order every thing is considered as a resource |
Action Based:Here we use Action – getCustomer, getProduct, getPurchaseorder, getSalesorder |
Can be represnted in XML or JSON (JAVA SCRIPT OBJECT NOATION) format |
Can be represented in XML format. |
JSON is a light-weitht data format easy to read,write and machines to parse. Where as XML is heavyweight as compared to JSON. When some application you want to view on mobile device, then JSON is the preferred format over XML for many mobile and web application. JSON doesn’t use tag , it is quicker and shorter and uses array. |
A simple employee array representation with JSON and XML:
JSON:
{“employees”:[
{ “firstName”:”John”, “lastName”:”Doe” },
{ “firstName”:”Anna”, “lastName”:”Smith” },
{ “firstName”:”Peter”, “lastName”:”Jones” }
]}
XML:
<employees>
<employee>
<firstName>John</firstName> <lastName>Doe</lastName>
</employee>
<employee>
<firstName>Anna</firstName> <lastName>Smith</lastName>
</employee>
<employee>
<firstName>Peter</firstName> <lastName>Jones</lastName>
</employee>
</employees>
Open the below URL in chrome browser and open the developer tool.
http://services.odata.org/V2/Northwind/Northwind.svc/Products
The service opens the PRODUCTS entity set in XML format and size is 34.3 KB.
http://services.odata.org/V2/Northwind/Northwind.svc/Products?$format=json
Open the same service PRODUCTS entity set in JSON format, the size is 15KB.