3

I have a requirement where I have large amount of data(in form of pdf,images,doc files) on server which will be distributed to many users. I want to pull these file using web services along with their meta-data. I will be getting the files in bytes. I am confused in which type of web service will be more secure, easy to parse? Which one is easy to implement on iPhone client?

I know REST is simpler but I read somewhere that it is not suitable for distributed environment. At the same time SOAP is too heavy for mobile platform.

I have searched many sites describing how REST is easier and how SOAP is secure. I got confused about which one to use? Also about the kind of response, which will be better JSON or XML for my requirement?

thatguy
  • 312
  • 1
  • 6
  • 19

2 Answers2

2

For your requirements JSON will be the best kind of response because it is way smaller than XML (More than 50% smaller in many tests). You can use SBJSON (https://github.com/stig/json-framework/) to parse it easily on iOS.

Concerning REST or SOAP, the last one is indeed really heavy for mobile platform and not so easy to implement. SOAP requires XML too and cannot be used with JSON. Whereas with REST you can use JSON or XML and easily implement it on iOS with RESTKit (http://restkit.org/), for security you can use an SSL connection with HTTPS and a signed certificate.

The only advantage of SOAP is the WSDL (Webservice specification) which made your webservices really strong.

iGranDav
  • 2,450
  • 1
  • 21
  • 25
  • I agree but can json handle byte data stream as effectively as xml does? – thatguy Sep 22 '11 at 09:12
  • 2
    JSON does not handle byte data stream natively, you have to encode your data in **base64** to handle byte data. This [subject](http://stackoverflow.com/questions/1443158/binary-data-in-json-string-something-better-than-base64) talk about it. – iGranDav Sep 22 '11 at 12:41
  • What exactly is it about the Web services spec that makes "webservices strong"? – Jan Algermissen Sep 27 '11 at 20:12
  • Because of the WSDL, you are sure that your client and your server have the same implementation. With REST Webservices, you can migrate your server without having to migrate your clients... – iGranDav Sep 28 '11 at 15:04
0

Unless you have a specific requirement to pull the file data and the metadata in the same response, you might consider just pulling down the file with a regular HTTP GET. You can get decent security with HTTPS and Basic Auth or client certificates. I would then include a Link header pointing to the metadata for your file, as in:

Link: </path/to/metadata>;rel=meta

In particular, this lets you have separate caching semantics for the file itself and for its metadata, which is useful in the common case where the files are much larger than their metadata and where metadata can change without file contents changing.

Jon Moore
  • 1,370
  • 10
  • 11