Apache XML RPC客户端库等效调用使用OkHttp3为Odoo v9 Web服务API



我想使用OkHttp3库连接Odoo v9 server为我的Android应用程序。有oodoo -rpc-v3已经可用,它内部使用android Volly library,有时使用throws NullPointerException,没有error messages,这超出了我的控制范围。使应用程序崩溃。这里是Odoo v9 Web服务API文档,它是使用Apache XML-RPC库Java中编写的。我想使用OkHttp3库执行相同的调用。

call是:
1. 登录

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. 调用方法

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); }}
));
最终我想使用XML-RPC使用OkHttp3。欢迎任何建议、指导或帮助。

最后我用Odoo json-rpc完成了这个。下面是演示。如果你喜欢,请给我打个星号。

最新更新