DeBortoliWines / openerp-java-api

A Java API to connect to OpenERP and manage data using the XMLRPC interface.
Apache License 2.0
38 stars 71 forks source link

callFunction fail #13

Closed charles1850 closed 7 years ago

charles1850 commented 9 years ago

hi, I would like to use callFunction .But every time it fails。 openerp8,openerp-java-api 1.5 pice code: Session s = new Session( OpenERPXmlRpcProxy.RPCProtocol.RPC_HTTP, "localhost",8069,"sentai", "admin", "admin"); s.startSession(); ObjectAdapter oa = new ObjectAdapter(s, "im_chat.session"); HashMap<String, Object> values = new HashMap<String, Object>();

    values.put("user_to", 5);

    Object[] params = new Object[] {values};
    FieldCollection fields=oa.getFields();
    RowCollection rc= oa.callFunction("session_get",params,fields);

Exception: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer at org.apache.xmlrpc.parser.XmlRpcResponseParser.addResult(XmlRpcResponseParser.java:61) at org.apache.xmlrpc.parser.RecursiveTypeParserImpl.endValueTag(RecursiveTypeParserImpl.java:78) at org.apache.xmlrpc.parser.XmlRpcResponseParser.endElement(XmlRpcResponseParser.java:186) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:186) at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:156) at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143) at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69) at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56) at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167) at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137) at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126) at com.debortoliwines.openerp.api.Session.executeCommand(Session.java:197) at com.debortoliwines.openerp.api.OpenERPCommand.callObjectFunction(OpenERPCommand.java:171) at com.debortoliwines.openerp.api.ObjectAdapter.callFunction(ObjectAdapter.java:826) at odootest.imchat.main(imchat.java:71)

    Can you give me an example of callFunction.

Regards, Charles

flotho commented 9 years ago

Hy, If I remember well, livechat is not listening on 8069. If you set up the odoo instance with workers <> 0 a longpolling thread should be listening on the port 8072. Check this and give it a try on port 8072

charles1850 commented 9 years ago

Hy, try on port 8072.return: org.apache.xmlrpc.XmlRpcException: Failed to read server's response: Connection refused: connect

I use im_chat,not im_livechat.

Can you give me an example of callFunction.

charles1850 commented 9 years ago

just an example of callFunction.dont care of im_chat.

flotho commented 8 years ago

Try something with execute command

            openERPSession.executeCommand("product.template", "create_variant_ids", 
                    new Object[]{Integer.valueOf(product_id)});

Source : http://sourceforge.net/p/openerpjavaapi/wiki/Class%20Overview/ Using OpenERPCommand on object adapter could cause troubles if the result is not a list of ids Using executeCommand will call a law level xmlrpc without any wrapping.

Hope it helps