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.
Related
So I'm building a mobile app which will be using a RESTful web service (which I am also writing myself)
After lots of research I have a few questions regarding mobile apps and the HATEOAS constraint.
I usually use the Gson library for parsing objects without the HATEOAS constraint and it has been proven to be really efficent. For HATEOAS however, I am thinking of using Gson for the deserialization and Json-HAL for the response format.
How do I parse all of the _links and _embedded resources in my application without making the deserialization process tiresome? Some objects could have "embedded" resources and some don't. How should I create my data model objects to support all of these new tags? I am pretty lost on this part so I would appreciate an example.
Does anyone have any tips implementing this constraint on mobile apps?
If you think HAL or Json is not the right choice for mobile, please let me know.
Implementing this constraint for mobile seems like overkill to me.
Please enlighten me, Thanks!
Bit late to the party, but I feel that the best way to solve this is, summed up:
Yea HAL is a good format.
Treat things in _links and things in _embedded both as links. They are really the same 'thing'.
The difference with _embedded compared to _links though, is that _embedded really should pre-populate your cache. So whatever you receive their should be added to some kind of cache which should make future GET requests unneeded for those resources.
The benefit of this approach is that it now becomes possible for the server to 'promote' links from _links to _embedded and have your client automatically adapt to this and make less HTTP calls.
References: (disclaimer, I wrote both)
The problems with embedding in REST today and how HTTP/2 might solve it.
Restl, a hypermedia client for javascript
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.
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.
What are the best practices to design webservices for mobile (particularly Android) apps?
Personally I'm focused on using JSON (and not XML) and I try to make it the less verbose I can. But I'm probably missing a lot of things.
The stuff I've read so far indicates that there is too much of a processing overhead when calling a traditional webservice using SOAP and parsing xml. The best advice was to make your webservice RESTful and use JSON. There's some good information on this earlier question:
How to call a SOAP web service on Android
XML parsing on Android is supposed to be faster than the built-in JSON parser as the former is backed by native code. However, some people have used a different JSON parser (http://jackson.codehaus.org/) with success.
The GSON parser also works well with Android in my experience. Given that a shot if you're sending / received JSON payloads.
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.