Webservice in iOS Swift

Jan 17, 2022 iOS

Types of Webservice in iOS Swift

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 : 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.



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 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


body (WSDL)

SOAP contains real XML Content  as Request and Response

XML Request

  1. <Envelop xmlns=?http://schemas.xmlsoap.org/soap/envelop/?>  
  2.     <Body>  
  3.         <getCourseDetailRequest xmlns=?http://leadbycode.com/blog?>  
  4.             <id>course1</id>  
  5.         <getCourseDetailRequest>  
  6.     </Body>  
  7. </Envelop>  
XML Response
  1. <SOAP-ENV:Envelope xmlns:SOAP-ENV=?http://schemas.xmlsoap.org/soap/envelope/?>  
  2.           <SOAP-ENV:Header />             <!?empty header–>  
  3.            <SOAP-ENV:Body>                <!?body begin–>  
  4.                   <ns2: getDetailpostResponse xmlns:ns2=?http://leadbycode.com/post> <!–content of the response–>  
  5.                    <ns2:course>  
  6.                     <ns2:id>blog</ns2:id>  
  7.                     <ns2:name>Coredata<ns2:name>  
  8.                     <ns2:description>swift</ns1:description>  
  9.                     </ns2:psot>  
  10.                     </ns2:getpostResponse>  
  11.                </SOAP-ENV:Body>       <!?body end–>  
  12. </SOAP-ENV:Envelope>