What is Web Service ?
Webservice in iOS Swift : A web Service is the package which is used to communicate between the two node(Device) using the network.
There are 2 types of WebService Call
1. SOAP Web Service
2. REST Web Service
REST
REST : It is known as REpresentational State Transfer. It is the Established the resources through the use of the URL to transport the protocols like GET, DELETE, POST,PUT.
It mostly Concern more on the resource. It inherit security measures from the underlying transport protocols. It accept Different format of data like Plain Text,HTML,JSON,XML etc.
Example:
http://{serverAddress}/leadbycode/post
The method used in HTTP Service are
GET : To read the Data
PUT : to update the exiting Data
POST : To create a new Data
DELETE : To delete the Data
The Standard status code in REST are
404: Data not found
200 : Success
201: Create
401: Unauthorised
500 : Server Error
Advantages of RESTFul web service
- it is plateform-independent
- it provide different data format like JSON, text , HTML and XML.
- they are reusable.
- they can be written in any programming langauge.
SOAP
SOAP is known as Simple Object Access Protocol. It is XML Based Protocol. Its biggest advantages is the security .Soap is basically used in enterprise application, in legacy code. It uses XML for the network call over HTTP.
Soap Envelop Structure consist of
Header
body (WSDL)
SOAP contains real XML Content as Request and Response
XML Request
- <Envelop xmlns=?http://schemas.xmlsoap.org/soap/envelop/?>
- <Body>
- <getCourseDetailRequest xmlns=?http://leadbycode.com/blog?>
- <id>course1</id>
- <getCourseDetailRequest>
- </Body>
- </Envelop>
- <SOAP-ENV:Envelope xmlns:SOAP-ENV=?http://schemas.xmlsoap.org/soap/envelope/?>
- <SOAP-ENV:Header /> <!?empty header–>
- <SOAP-ENV:Body> <!?body begin–>
- <ns2: getDetailpostResponse xmlns:ns2=?http://leadbycode.com/post> <!–content of the response–>
- <ns2:course>
- <ns2:id>blog</ns2:id>
- <ns2:name>Coredata<ns2:name>
- <ns2:description>swift</ns1:description>
- </ns2:psot>
- </ns2:getpostResponse>
- </SOAP-ENV:Body> <!?body end–>
- </SOAP-ENV:Envelope>
%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20value%3D%22%22%20style%3D%22rounded%3D0%3BwhiteSpace%3Dwrap%3Bhtml%3D1%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22260%22%20y%3D%22150%22%20width%3D%22190%22%20height%3D%22280%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%223%22%20value%3D%22%22%20style%3D%22rounded%3D0%3BwhiteSpace%3Dwrap%3Bhtml%3D1%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22280%22%20y%3D%22190%22%20width%3D%22150%22%20height%3D%2260%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3CmxCell%20id%3D%224%22%20value%3D%22%22%20style%3D%22rounded%3D0%3BwhiteSpace%3Dwrap%3Bhtml%3D1%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22280%22%20y%3D%22270%22%20width%3D%22150%22%20height%3D%22130%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E