Skip to Content
Menu
This question has been flagged
1 Reply
17469 Views

Hi Friends ,

I am learning OpenERP XML-RPC API for JAVA, I tried some code, but the READ operation is not working for me .

I am using IDE - Java Eclipse & my program looks like

package TalendDemo;
import java.net.URL;
import java.util.HashMap;
import java.util.Vector;

import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;

public class Read {

@SuppressWarnings("unchecked")
public static void main(String args[]) throws Exception {

    try {
        XmlRpcClient client = new XmlRpcClient();
        XmlRpcClientConfigImpl clientConfig = new XmlRpcClientConfigImpl();
        clientConfig.setEnabledForExtensions(true);
        clientConfig.setServerURL(new URL("http", "localhost", 8069,
                "/xmlrpc/object"));
        client.setConfig(clientConfig);
        Vector<Object> arg = new Vector<Object>();

        arg.add("Talend");             // DB name
        arg.add(1);                    // used_id
        arg.add("admin1234");          // DB password
        arg.add("res.partner");        // table 
        arg.add("read");
        arg.add(5);                    // Table id 
        arg.add("name");               // column name 

        HashMap<Object, Object> ids = new HashMap<Object, Object>();
        ids = (HashMap<Object, Object>) client.execute("execute", arg);
        System.out.println(ids);
        System.out.println(ids.size());

    }

    catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

}

Output :

{id=5}
1

My Question is the output be Returns: the id of each record and the values of the requested field. But my return type is different. What is problem , help me ...

Thanks & Regards

OMPRAKASH.A

Avatar
Discard
Best Answer

The table ID must be a list (or array) if ids "[5]", not an integer "5".

Avatar
Discard
Author

Hai Fabien Pinckaers , Thanks for your reply .. Even if i changed my table ID as list getting error as -Failed to parse servers response: Unexpected non-whitespace character data .. What to do ? please reply & Once again thanks for your reply

Related Posts Replies Views Activity
0
Aug 22
2157
1
Dec 19
11357
0
Jan 25
625
1
May 23
7107
1
Oct 20
5249