I need to synchonize some data accross different phones. For example I want to enable "friends" to (automatically) share notes...
I'm now wondering what would be the best approch to reach this.
At the moment i think I'll have to write my own webservise to reach this goal.
As I started to think about a SOAP webservice I found lots of people saying that they would prpose a REST approach.
What would be the "better" solution in my case or are there any other approches for synchonizing data on different Android phones?
Maybe I should start by mentioning that REST is not a protocol and as such hard to compare to SOAP which is.
The main disadvantages with using SOAP for mobile applications are that it normally uses XML and thereby more data than most other protocols and that it's fairly complex both to set up and to maintain. On the other hand, if one party writes the server and one the client, SOAP gives you good ways to see to that changes are communicated clearly (ie WSDL). SOAP is generally not very well supported in mobile phones and may require third party libraries to make it work.
REST is often (mis)used as a name for HTTP based communication using JSON, which is a pretty easy way to communicate with mobile devices and has low overhead. If you have control over both server and client, it's not the wrong way to go (but not the only one either) JSON is generally very easy to get to work on all mobile platforms, and HTTP is well supported by the phones themselves.
It's better to use REST than SOAP because SOAP is very verbose and will increase the network data size.
Besides, if you use SOAP, you have to include external librairies (like kSOAP) to consume the response. With REST, a standard HTTP client is OK.
About data format: think about JSON that is less verbose than XML.
Concerning synchronization, I don't know if Android SDK provides classes to perform this work.
Related
I want to develop client - server system (client is mobile). What the best way to transfer the data from server and to server? Using RESTful-architecture? HTTP requests? use JSON or XML?
If there isn't best way what is the advantages and disadvantages of each method?
Thanks for helping.
This is a very subjective question. You can use anything to transfer data to mobile devices, even a direct socket binary transfer. But as you have stated, one of the most popular methodologies is to use a REST-ful JSON interface. There are good libraries that support this system both on the client and server. The other option which is not as popular anymore is using XML/SOAP. Many people loathe XML/SOAP at this point, some don't mind. Of course, there are many others I will not mention.
As I stated before though, this is a subjective question. If I were to do this work, I would do REST/JSON, but it certainly is not the only way.
What is the difference between SOAP and RESTful Architecture and how I can use them in Android? My application is a booking engine car, I am still confused. Can someone help me to see the difference between those, and how I can Apply in an Android application with example please. Also how i can use the MVC Architecture
REST (REST describes a set of architectural principles by which data can be transmitted over a standardized interface) is almost always going to be faster. The main advantage of SOAP (SOAP defines a standard communication protocol specification for XML-based message exchange)is that it provides a mechanism for services to describe themselves to clients, and to advertise their existence.
REST is much more lightweight and can be implemented using almost any tool, leading to lower bandwidth and shorter learning curve. However, the clients have to know what to send and what to expect.
In general, When you're publishing an API to the outside world that is either complex or likely to change, SOAP will be more useful. Other than that, REST is usually the better option.
The most common way to consume SOAP based services on Android seems to be via kSOAP2 since it's recommended here on stackoverflow very often. I'm a fan of SOAP since I've been working with JAX-WS for a while.
But even the people behind kSOAP2 do not recommend it for mobile devices. I know that SOAP produces a lot of overhead you don't want to have on your mobile device. Do you have any experience with SOAP based services consumed by Android, is it really an issue? What is the main bottleneck, bandwidth or memory/cpu?
I need to transmit text and binary data, is REST the best alternative here?
Thanks
edit: If possible I want to avoid to build a parser by myself, should work without own parser. Maybe GSON?
I need to transmit text and binary data, is REST the best alternative
here?
yes. you can send binary data via HTTP POST, and sending text is trivial with REST. I suggest you to use JSON format as it is light weight and highly accepted through developers so you can find a lot of examples.
see http://www.springsource.org/spring-android for library for Android to automates JSON to object and vice versa generations.
JSON or XML over Http for text data. Http POST for binary data. Whether it should be REST or not is really up to you.
I have seen the video http://www.youtube.com/watch?v=xHXn3Kg2IQE and it was very interesting.But any one have implemented the REST web service using the services.I am developing the chat app,i need to call the web services in some interval if any one done it then please send me idea about it.
Thank you.
I know you've seen my question about the android restful API service, and think you can do something similar the the answers stated there. You'll need to use a Handler to execute a timed callback from the service.
Also, since that question was answered I've discovered google buffers which may be worth you looking at:
Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages. You can even update your data structure without breaking deployed programs that are compiled against the "old" format.
There are some good examples on the tutorial pages - it'll make your chat client super fast!
I need to get an Android app to interface with an XML webservice (it's really just a request which returns XML), but as the data is large and includes some things I don't need (like a huge description block), I was thinking of transforming it via a server into a format that would be good for Android, and also to be reduced considering it will be used in a low bandwidth area.
Does anyone have any suggestions for a good lightweight protocol? I'm especially thinking about libraries for Android that already exist for say REST or even delimited data.
JSON is the alternative to XML. If you're debating whether or not JSON is the preferred way to go, both Twitter and Facebook are going to be getting rid of XML support for their REST APIs and only providing JSON. I'd go that route if possible. XML won't go away, that's a given, but it may just not be used anymore in RESTful APIs.
JSON is very lightweight, so you could use that. I'm sure there are libraries already written to encode/decode it in Android.