Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

Using OpenERP XML-RPC API with Java

By
omprakash
on 2/22/13, 8:52 AM 5,224 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

0

Fabien Pinckaers (fp)

--Fabien Pinckaers (fp)--
6598
| 6 8 8
fsdsdfsdf, Belgium
--Fabien Pinckaers (fp)--

Odoo Founder & CEO

Fabien Pinckaers (fp)
On 3/1/13, 3:39 AM

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

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

omprakash
on 3/4/13, 3:09 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/22/13, 8:52 AM
Seen: 5224 times
Last updated: 3/16/15, 8:10 AM