views:

860

answers:

4

I've started my degree project, a mobile application suitable for iPhone, Android and (in the near future) Symbian. The server architecture is the following:

  • web site (for "standard" users);
  • web service (for mobile connections), based on TomCat and Axis2;
  • mySQL DB to storage users data.

Surfing across the web, I've read a lot of discussion about the interaction between the iPhone and Web Services, and I've to say that I've not a clear idea of what I can do and what not. Let's start from the protocol used to retrieve data from the DB: the Android-side application uses SOAP protocol, can I do the same with iPhone? Are there some limitations or problems?

I have also read about the using of REST instead of SOAP, could it be possible with the server architecture described above? Which are the main advantages/disadvantages?

Sorry if these questions sound "n00b", but it's my first real experience with iPhone and the lot of informations found on the web messed up my mind and I'm scared to be confused. Forgive me for any error.

+1  A: 

You can definitely do SOAP on the iPhone. Here is a nice tutorial on the subject. After all, SOAP is a HTTP based protocol and you have all the libraries you need to do HTTP on the iPhone.

Having said that, RESTful APIs are simpler than SOAP, so you might want to consider them. They're also HTTP based so you won't have any problems on doing that on iPhone. On the server side, if you use Java, you will have to use JAX-RS to implement that part.

Hope it helps.

Pablo Santa Cruz
I've seen the tutorial and used few days ago, but it seems that there's no way to make it run on the device. I think it's because NSXMLParser is not included into the device, so a "workaround" is use libxml2 instead, but it requires a lot of additional lines and I belive that the resulting code is not human readable, even if you comment it.
Maury
A: 

Google Buffers

If your looking for a language and platform agnostic solution have a look at Google Buffers. You can easily serialise objects for transmission over the wire.

This question should get you started in Objective-C.

JSON

I have also used JSON within iPhone Apps with great success. Again, relatively language and platform agnostic but much simpler than Google Buffers.

rjstelling
+2  A: 

SOAP is simply too heavy for mobile communications. Why do all the work to wrap requests in an additional XML layer you'll have to parse? You send more data than you need to, and impose greater CPU burden on client and server.

Use REST. If you are doing a cross-platform project JSON makes a great payload container, otherwise plists work well for sending data from the server.

Kendall Helmstetter Gelner
SOAP does not mean XML. It can also be Fast Infoset, which is optimized for small devices that have bandwidth constraints, and is supported by many vendors such as Microsoft .NET and .NET CF, Sun GlassFish, BEA WebLogic, IBM SDK for Java 6.0 and others. http://en.wikipedia.org/wiki/Fast_Infoset
mjustin
But that's just another layer, that does not eliminate the inherant wrapping nature of SOAP. The real issue with SOAP is that you end up using it on top of a protocol (HTTP) that already has features to do anything you can with SOAP (especially so with the subset of SOAP supported by most libraries). The equivalent of Fast Infoset for rest is to simply turn on GZIP compression on the server and both sides do nothing else. Yes SOAP can also be used on other protocols but in practice, it almost ever is and certainly is not in 99% of small devices accessing web services.
Kendall Helmstetter Gelner
A: 

SOAP with Fast Infoset is suited for small devices:

JAX-WS 2.0 and its reference implementation support both Fast Infoset and MTOM/XOP. This article includes information about Web Service Performance for Fast Infoset vs. MTOM/XOP:

http://www.devx.com/xml/Article/35385/1954

Fast Infoset is optimized for small devices that have bandwidth constraints, and is supported by many vendors such as Microsoft .NET and .NET CF, Sun GlassFish, BEA WebLogic, IBM SDK for Java 6.0 and others.

http://en.wikipedia.org/wiki/Fast%5FInfoset

mjustin