Consuming SOAP web services in Android
Consuming SOAP web services in android is a hugely discussed topic and one can find a lot of discussion and “opinions” about its usage and they way one manipulates data in mobile devices especially in android.
It’s pretty common for android developers to use web services, mmm.. no, let me rephrase,
It’s pretty common for every developer to write code which consumes data from a web service.
Because this is the world we’re living in at the moment, where, a server serves as a data host for different clients like web, mobile, others etc) and other servers using data protocols such as HTTP, Ftp, SOAP etc.
The most common protocol you’ll use is REST, which means that all the data transferred is basically represented as Json Strings, which is probably the best way to do it, because Json is very easy to understand, parse and generate both on client side, and on server side.
A question arises.. ? SOAP Or Restful ?
I personally recommend and use Restful web services.
Android has great built in support for consuming Restful web services, but very low support for SOAP based web services.
Odds are, you’ll probably encounter a web service of this sort (one that is based on SOAP).
So what can we do ?
A suggested and common solution is to use the free open source library called KSOAP2. This library provides us with an easy API for generating requests and parsing responses in a SOAP format.
How do we use KSOAP2 ?
source code is available here: http://code.google.com/p/ksoap2-android/
Once downloaded, it can be included in the build path of the project, and if in some way you have a web service which forces you to work in a specific format of requests, you can download the entire source code and start modifying it as you wish.