SOAP, REST, or just XML to solve Objective-C / iPhone vs server

We are going to set up a solution in which iPhone requests data from the server. We have the opportunity to decide which solution to put in place, and we are not sure where to go.

As for SOAP, I think I have an answer, there is no really stable solution for this (I know there are solutions, but I want something stable).

How about REST?

Or is it better to just create your own XML? This will not be such a complex regulator / stream of responses.

Thanks in advance!

+4
source share
6 answers

You do not say how complex your data structures are and if you really need state handling.

If you want your network traffic to be minimal while preserving some structured XML functions, you can look at JSON . This is a very lightweight data encapsulation structure. Some versions are available for iPhone, for example TouchJSON

Klaus

+3
source

I created an open source application for iPhone OS 3.0 that shows how to use REST and SOAP services in an 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 the sample PHP application (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 SlideShare presentation shows my results in terms of performance, ease of implementation, and useful features:

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

I basically found in my tests that Binary Plists + REST + JSON and XML + TBXML library are the β€œbest” options (which means: ease of implementation + deserialization speed + lowest payload size).

The Github project has a results folder with an Excel worksheet that summarizes the results (and with all raw data). You can also run tests yourself on 3G or Wi-Fi, and then send the results by mail for comparison and study.

Hope this helps!

+8
source

REST is the way to go. There are SOAP solutions, but given that all users end up doing SOAP, they can still be done using RESTful services, there is simply no need for overhead (SOAP calls transfer XML data inside an XML envelope, which also need to disassemble).

What makes REST an excellent approach is that it makes full use of the HTTP protocol, not only to receive data, but also to publish (create) or delete things. HTTP has standard messages specific to problems with all of these things, and a decent authentication model to download.

Since RESTs are just HTTP calls, you can choose which data transfer method best suits your needs. You can send and receive XML if you want, although JSON is easier to parse and send less. Plists is another popular format, as you can send richer data types and are slightly more structured than JSON, although on the server side you usually have to look for libraries to create it.

Many people use JSON, but beware that it is very subtle because of the parsing - spoil the character at the beginning of the line or accidentally get the lines there without leaving the characters "", and there may be problems.

+7
source

XML property lists (plist) are also a common way to serialize data in Cocoa. It is also trivial to generate from other languages, and there are some good libraries.

+5
source

I would go with simple HTTP. NSURLConnection in Cocoa libraries makes this pretty straightforward. Google Toolbox for Mac also has several classes to help you analyze URL encoded data.

+2
source

I think that it is obvious that REST is the new king of communication with servers, you should definitely use REST, the questions should be what REST methodology you should use and what coding language in my post I present some very simple implementations for REST servers in C #, PHP, Java and node.js.

0
source

Source: https://habr.com/ru/post/1304498/


All Articles