1
我想使用xml-rpc從WS獲取數據。 連接成功,但是當我在name_search方法設置的參數,我有此異常:從php客戶端的xml-rpc搜索方法錯誤
error : Traceback (most recent call last):
File "/home/openerp/odoo/odoo/openerp/service/wsgi_server.py", line 82, in xmlrpc_return
result = openerp.netsvc.dispatch_rpc(service, method, params)
File "/home/openerp/odoo/odoo/openerp/netsvc.py", line 296, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/home/openerp/odoo/odoo/openerp/service/web_services.py", line 626, in dispatch
res = fn(db, uid, *params) File "/home/openerp/odoo/odoo/openerp/osv/osv.py", line 132, in wrapper
return f(, dbname, *args, **kwargs)
File "/home/openerp/odoo/odoo/openerp/osv/osv.py", line 199, in
res = ._cr(cr, uid, obj, method, *args, **kw)
File "/home/openerp/odoo/odoo/openerp/osv/osv.py", line 187, in _cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/home/openerp/odoo/esigpen/prison_person/prison_person.py", line 287, in name_search
('identificador', 'ilike', name)] + args
TypeError: can only concatenate list (not "NoneType") to list
我使用PHPXMLRPC-2.2.2庫的連接,並通過我送$參數VAL。在這種情況下,我正在發送名稱cris。
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
require_once('phpxmlrpc-2.2.2/lib/xmlrpc.inc');
require_once('phpxmlrpc-2.2.2/lib/xmlrpcs.inc');
$GLOBALS['xmlrpc_internalencoding']='UTF-8';
$dbname = '*****';
$user = '****';
$password = '****';
$server_url = 'http://23.000.160.000:8069';
$connexion = new xmlrpc_client($server_url . "/xmlrpc/common");
$connexion->setSSLVerifyPeer(0);
$c_msg = new xmlrpcmsg('login');
$c_msg->addParam(new xmlrpcval($dbname, "string"));
$c_msg->addParam(new xmlrpcval($user, "string"));
$c_msg->addParam(new xmlrpcval($password, "string"));
$c_response = $connexion->send($c_msg);
if ($c_response->errno != 0){
echo '<p>error : ' . $c_response->faultString() . '</p>';
}
else{
$uid = $c_response->value()->scalarval();
$val = array (
new xmlrpcval(
array(new xmlrpcval('cris', "string"),
),"array"
),
);
$client = new xmlrpc_client($server_url . "/xmlrpc/object");
$client->setSSLVerifyPeer(0);
$msg = new xmlrpcmsg();
$msg->addParam(new xmlrpcval($dbname, "string"));
$msg->addParam(new xmlrpcval($uid, "int"));
$msg->addParam(new xmlrpcval($password, "string"));
$msg->addParam(new xmlrpcval("prison.person", "string"));
$msg->addParam(new xmlrpcval("name_search", "string"));
$msg->addParam(new xmlrpcval($val, "struct"));
$response = $client->send($msg);
if ($response->errno != 0){
echo '<p>error : ' . $response->faultString() . '</p>';
}
$result = $response->value();
$ids = $result->scalarval();
}
?>
這是Python代碼,其中包括:方法來搜索:
https://gist.github.com/name1984/a7e78af7dba738449bc0
謝謝您的幫助。