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.

0

Why does my XMLRPC path return a 404 error?

By
Daniel DeLoretta
on 4/24/13, 3:09 AM 3,541 views

I am using OpenERP version 7 (default install) on my own server (CentOS 6) however I cannot connect via XMLRPC.

Please note: I lack sufficient priviliges to post "links" - where you see [http://] you can assume it is http://

wget [http://]my.server:8069/xmlrpc/
root@srv2578a [~]# wget [http ://]my.server:8069/xmlrpc/
--2013-04-24 11:27:49--  [http://]my.server:8069/xmlrpc/
Connecting to my.server:8069... connected.
HTTP request sent, awaiting response... 404 NOT FOUND
2013-04-24 11:27:49 ERROR 404: NOT FOUND.

I have checked in my openerp-server.conf file and the following xmlrpc related items are (in this order):

#i believe the blank interface is listening on all IPs?
xmlrpc_interface =
xmlrpc_port = 8069
xmlrpc = True

I can connect to the website and log in and perform tasks just fine. I wish to automate some things using the XMLRPC feature and PHP.

I am using the following to attempt to connect via XMLRPC (it should return my userid):

<?php

include_once("xmlrpc-2.2.2/lib/xmlrpc.inc"); 
class OpenERPXmlrpc {

    private $user, $password, $database, $services, $client, $res, $msg, $id;

    function __construct($usr, $pass, $db, $server) {

        $this->user = $usr;
        $this->password = $pass;
        $this->database = $db;
        $this->services = $server;

        $this->client = new xmlrpc_client($this->services.'common'); 
        $this->msg = new xmlrpcmsg('login');
        $this->msg->addParam(new xmlrpcval($this->database, "string"));
        $this->msg->addParam(new xmlrpcval($this->user, "string"));
        $this->msg->addParam(new xmlrpcval($this->password, "string"));
        $this->res =  &$this->client->send($this->msg);

        if(!$this->res->faultCode()){
            $this->id = $this->res->value()->scalarval();
        }
        else {
            echo "Unable to login ".$this->res->faultString();
            exit;
        }
    }

    function read($post = null) {

        $this->client = new xmlrpc_client($this->services.'object');
        if(empty($post)) {
            $ids_read = array(new xmlrpcval('1', 'int'), new xmlrpcval('2', 'int'));
            $key = array(new xmlrpcval('id','integer') , new xmlrpcval('name', 'string'));
            $this->msg = new xmlrpcmsg('execute');
            $this->msg->addParam(new xmlrpcval($this->database, "string"));
            $this->msg->addParam(new xmlrpcval(1, "int"));
            $this->msg->addParam(new xmlrpcval($this->password, "string"));
            $this->msg->addParam(new xmlrpcval("res.partner","string"));
            $this->msg->addParam(new xmlrpcval("read", "string"));
            $this->msg->addParam(new xmlrpcval($ids_read, "array"));
            $this->msg->addParam(new xmlrpcval($key, "array"));

            $this->res = &$this->client->send($this->msg);
            if(!$this->res->faultCode()) {
                $read_html = '<table width="20%" border="0" cellpadding="4" cellspacing="4" align="center">
                        <tr>
                           <th>Id</th>
                           <th>Name</th>
                        </tr>
                     ';

                $scalval = $this->res->value()->scalarval();
                foreach ($scalval as $keys => $values) {
                    $value = $values->scalarval();
                    $read_html .= '
                     <tr>
                        <td>'.$value['id']->scalarval().'</td>
                        <td>'.$value['name']->scalarval().'</td>
                     </tr>
                     <tr><td colspan="2"></td></tr>';
                }
                $read_html .= '</table>';
                return $read_html;
            }
            else {
                return "Not read recode from partner table <br />".$this->res->faultString();
            }
        }
    }

}

$cnt = new OpenERPXmlrpc('user.name', 'password', 'DATABASE01', '[http://]my.server:8069/xmlrpc/');

echo $cnt->read();

// outputis this:
// Unable to login Connect error: Connection timed out (110)
?>

Has anyone else encountered this?

Anybody care to share some thoughts on this issue?

0
Daniel DeLoretta
On 4/30/13, 4:46 AM

Oh! What a simple fix. It would appear you have to open the ports on both the client and the server machines so they can talk.

I simply added port 8069 to the in/out allow chain in iptables.

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: 4/24/13, 3:09 AM
Seen: 3541 times
Last updated: 3/16/15, 8:10 AM