1

I want to use OkHttp3 library to connect with Odoo v9 server for my Android application. There's odoo-rpc-v3 already available which internally uses android Volly library and sometimes throws NullPointerException with no error messages which is out of my control & crashes the application. Here's the Odoo v9 Web Services API Docs which is wriiten using Apache XML-RPC library in Java. I want execute same call using of OkHttp3 library.

The Calls are:
1. Logging in

final XmlRpcClient client = new XmlRpcClient();
final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
common_config.setServerURL(
    new URL(String.format("%s/xmlrpc/2/common", url)));
client.execute(common_config, "version", emptyList());
int uid = (int)client.execute(
    common_config, "authenticate", asList(
        db, username, password, emptyMap()
    )
);


2. Calling methods

final XmlRpcClient models = new XmlRpcClient() {{
    setConfig(new XmlRpcClientConfigImpl() {{
        setServerURL(new URL(String.format("%s/xmlrpc/2/object", url)));
    }});
}};
models.execute("execute_kw", asList(
    db, uid, password,
    "res.partner", "check_access_rights",
    asList("read"),
    new HashMap() {{ put("raise_exception", false); }}
));

Ultimately I want to use XML-RPC using OkHttp3. Any suggestions, guidelines or help are welcome. Thanks in advance.

Kasim Rangwala
  • 1,765
  • 2
  • 23
  • 44
  • Hey Can you help me in this?https://stackoverflow.com/questions/46067346/is-there-anyone-integratted-odoo-with-android – Noufal Sep 08 '17 at 05:14
  • Yes, use jsonRPC, there're lot of jsonRPC library already written in JS. Write down same in Java. Look at this https://github.com/akretion/odoo-json-rpc – Kasim Rangwala Sep 08 '17 at 05:27
  • Also look at https://github.com/Odoo-mobile/framework – Kasim Rangwala Sep 08 '17 at 05:38
  • Which xml-rpc jar file is you used?? – Noufal Sep 08 '17 at 05:55
  • for offline capability I use https://github.com/Odoo-mobile/framework for normal app I write own my HTTP request by getting help from OdooWrapper.java at https://github.com/Odoo-mobile/framework/blob/master/app/src/main/java/com/odoo/core/rpc/wrapper/OdooWrapper.java – Kasim Rangwala Sep 08 '17 at 05:57
  • this frame work is for creating apps right?? – Noufal Sep 08 '17 at 05:59
  • yes, https://github.com/Odoo-mobile/framework is use for creating apps – Kasim Rangwala Sep 08 '17 at 06:01
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/153922/discussion-between-noufal-and-ka7im1011). – Noufal Sep 08 '17 at 06:02

1 Answers1

0

Fianlly I've done this using Odoo json-rpc. here's the demo. If you like it, give me a star :).

Kasim Rangwala
  • 1,765
  • 2
  • 23
  • 44