Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SOAP, REST or just XML for Objective-C/iPhone vs. server solution

We are going to set up a solution where the iPhone is requesting data from the server. We have the option to decide what kind of solution to put in place and we are not sure about which way to go.

Regarding SOAP I think I have the answer, there are no really stable solution for doing this (I know there are solutions, but I want something stable).

How about REST?

Or is it better to just create our own XML? It's not going to be so complicated reguest/respons-flow.

Thanks in advance!

like image 585
Nicsoft Avatar asked Nov 28 '22 04:11

Nicsoft


2 Answers

I've created an open source application for iPhone OS 3.0 that shows how to use REST & SOAP services in iPhone application, using XML (using 8 different iPhone libraries), SOAP, JSON (using SBJSON and TouchJSON), YAML, Protocol Buffers (Google serialization format) and even CSV from a PHP sample app (included in the project).

http://github.com/akosma/iPhoneWebServicesClient

The project is modular enough to support many other formats and libraries in the future.

The following presentation in SlideShare shows my findings in terms of performance, ease of implementation and payload characteristics:

http://www.slideshare.net/akosma/web-services-3439269

Basically I've found, in my tests, that Binary Plists + REST + JSON and XML + the TBXML library are the "best" options (meaning: ease of implementation + speed of deserialization + lowest payload size).

In the Github project there's a "results" folder, with an Excel sheet summarizing the findings (and with all the raw data, too). You can launch the tests yourself, too, in 3G or wifi, and then have the results mailed to yourself for comparison and study.

Hope it helps!

like image 133
Adrian Kosmaczewski Avatar answered Dec 09 '22 15:12

Adrian Kosmaczewski


REST is the way to go. There are SOAP solutions, but given that all people end up doing with SOAP can be done with RESTful services anyway, there's simply no need for the overhead (SOAP calls wrap XML for data inside of an XML envelope which must also be parsed).

The thing that makes REST as an approach great is that it makes full use of the HTTP protocol, not just for fetching data but also posting (creating) or deleting things too. HTTP has standard messages defined for problems with all those things, and a decent authentication model to boot.

Since REST is just HTTP calls, you can choose what method of data transfer best meets your needs. You could send/receive XML if you like, though JSON is easier to parse and is smaller to send. Plists are another popular format since you can send richer datatypes across and it's slightly more structured than JSON, although from the server side you generally have to find libraries to create it.

Many people use JSON but beware that it's very finicky about parsing - mess up a character at the start of a line, or accidentally get strings in there without escaping "'" characters and there can be issues.

like image 44
Kendall Helmstetter Gelner Avatar answered Dec 09 '22 16:12

Kendall Helmstetter Gelner