aXMLRPC – A lightweight Android XML-RPC Client

aXMLRPC is a lightweight Java XML-RPC client which can be used on Android. The library has no dependencies to any 3rd-party library so it can function normally in any common Java virtual machine.

Include aXMLRPC in Android Studio

Firstly, you must include mavenCentral() in repositories list in build.gradle file.

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
}

Then import this library with

implementation 'fr.turri:aXMLRPC:1.12.0'

Use aXMLRPC

In the example code below, I tried to login to “https://demo.odoo.com/xmlrpc”.

 val listener = object : XMLRPCCallback{
    override fun onResponse(id: Long, result: Any?) {
        activity!!.runOnUiThread(object : Runnable{
            override fun run() {
                Toast.makeText(activity!!.applicationContext, "Welcome!", Toast.LENGTH_LONG).show() 
            }
        })
    }

    override fun onServerError(id: Long, error: XMLRPCServerException?) {        
    }

    override fun onError(id: Long, error: XMLRPCException?) {
    }

}

try {
    val client = XMLRPCClient(URL("https://demo.odoo.com/xmlrpc/2/common"))
    val response = client.callAsync(listener, "authenticate",
        database,
        username,
        password,
        "" )    
} catch (e: Exception){    
}

More ways to use the library can be found on https://github.com/gturri/aXMLRPC.

Leave a Comment

Your email address will not be published. Required fields are marked *