iPhone dealing with xml vs soap vs JSON vs RESTful

2019-07-22 09:45发布

问题:

I do not have much experience coding systems dealing with web-services. Please help me in solving following confusion.

One of my clients want me to build an iPhone App that had native UI controls but deals extensively with Web Services. Right from authenticating the user into a network to loading a list of users or anything related in the app will need to talk to a web service.

They have web services deployed on .NET on the server side and already have required data in SOAP web service. By doing some basic research on the web it seems that dealing with SOAP from an iPhone app could be messy and affect performance.

The client is ready to make the data available in from of JSON or plain XML data. I am not sure which one would be a better option? The data could range from few tens to few hundreds of rows only.

Can someone please point me how can I do a comparative study in short period of time (3-4 days) even if it takes for me to learn about the SOAP, XML, JSON and REST web services. Is this even possible or should I just go with some expert advice? - Waiting for expert advice :)

Thanks

回答1:

  • XML and JSON are data interchange formats. JSON is generally considered easier to work with, although a good library should make both palatable.
  • REST is an architectural style; it is the architectural style that HTTP is designed to support.
  • SOAP is a protocol for implementing web services, and it does not follow the REST architectural style; it's more of an Remote Procedure Call style.

I dislike SOAP because it forces you to rely on tools to manage many of its facets. If your tools happen to work differently than the tools used by the other end, then it becomes extremely painful.

I recommend reading RESTful Web Services for a general overview of REST, and why it's "better" than SOAP.

I don't have any good resources for SOAP, or anything iPhone specific.



回答2:

RESTFul webservices can return responses in XML or in JSon, the option of using such service is better than soap for iphone because of the overhead involved with soap as you mentioned. Basically when u get responses in xml or json its just some text that you need to parse. I would recommend going with Json as there are json parser libraries for iphone out there already and its very simple to use...Here is a tutorial for using the json parser and parsing your responses, Json tutorial...hope it helps