This is one very common question asked again and again on stack overflow and I read so many answers about this but I am still bit confused.
I need to call the webservices from iPhone sdk.
Here are my questions:
I am not clear what response SOAP or REST return.Is there anything specific that if response is XML then we should use REST and if JSON we should use SOAP?
What is the role of ASIHTTP with SOAP and REST?
If I am getting XML response as
<oproduct> <iid>113133791</iid> <icategoryid>270</icategoryid> <imerchantid>1547</imerchantid> <iadult>0</iadult> <sname>The Ashes / 1st Test - England v Australia - Day 1</sname> <sawdeeplink>http://www.acbcd.com/pclick.php?p=113133791&a=111402&m=1547&platform=cs</sawdeeplink> <sawthumburl>http://images.abcdd.com/thumb/1547/113133791.jpg</sawthumburl> <fprice>69.99</fprice> </oproduct>
Do I need to parse it by hand? or how do I handle XML response?
I got so many articles about REST and SOAP but no proper code to understand it. I would be grateful for any help regarding these questions.
SOAP - "Simple Object Access Protocol"
SOAP is a method of transferring messages, or small amounts of information, over the Internet. SOAP messages are formatted in XML and are typically sent using HTTP (hypertext transfer protocol).
So SOAP has a standard how a message has to be sent.
Each soap web service can be defined with a WSDL(Web Service Definition Language) which is kind of a schema for the SOAP XML transferred.
There are many tools available to convert WSDL(your webservice definition) to native code.
One of the tool available for ObjC is Sudz-C (http://sudzc.com/) which convert the WDSL of any webservice to ObjC code to access the Web service.
Rest - Representational state transfer
Rest is a simple way of sending and receiving data between client and server and it don't have any much standards defined , You can send and receive data as JSON,XML or even a Text. Its Light weighted compared to SOAP.
To handle Rest in iOS there are many tools available, I would recommend RestKit http://restkit.org/, for handling XML and JSON both.
I would suggest you to go with Rest for mobile development, since its light weight
(Simple example, People correct me If I am wrong)