Android and Magento Soap API – part I

09 January 2015

Magento is an open-source e-commerce solution. It may manage vast amounts of products, catalogs, orders and payment data which can be accessed by REST and SOAP APIs. Unfortunately REST API has limited access to this data and allows only download some of it. If full CRUD actions are needed it’s necessary to use SOAP API with XML format. That’s the day when you have to leave your comfort zone of REST & JSON and enter unfriendly waters.

Quick search lets you find ksoap2 library which allows you communicate with such API. There is an example of login to Magento by using ksoap2.

It’s pretty simple to get session id from server but whole code looks a bit old-fashioned (manually input parameters, catching connection exceptions, no built-in (de)serialization of complex objects). There is also next disadvantage – only synchronous API calls, so developer have to write some code to move it to the LoaderManager, Asynctask, Service or other, finally handle callbacks, and probably more NullPointerExceptions. Last but not least is necessity to learn new library when developers already are familiar with libs like Retrofit. In next posts I will show you how to access SOAP & XML API using Retrofit and SimpleXml.

These posts are being created because there is little information about how to connect Android to Soap API. The most useful source was this post on geekcalledk blog which shortly describes whole thing and in my opinion it’s worth to explore deeply this topic.

Bartek Kwiatkowski
Bartek Kwiatkowski