OpenERP: XML-RPC Web services (Example)


/ Published in: PHP
Save to your folder(s)

Here is an example on how to insert a new partner using PHP. This example makes use the phpxmlrpc library, available on sourceforge.


Copy this code and paste it in your HTML
  1. <?
  2.  
  3. include('xmlrpc.inc');
  4.  
  5. $arrayVal = array(
  6. 'name'=>new xmlrpcval('Fabien Pinckaers', "string") ,
  7. 'vat'=>new xmlrpcval('BE477472701' , "string")
  8. );
  9.  
  10. $client = new xmlrpc_client("http://localhost:8069/xmlrpc/object");
  11.  
  12. $msg = new xmlrpcmsg('execute');
  13. $msg->addParam(new xmlrpcval("dbname", "string"));
  14. $msg->addParam(new xmlrpcval("3", "int"));
  15. $msg->addParam(new xmlrpcval("demo", "string"));
  16. $msg->addParam(new xmlrpcval("res.partner", "string"));
  17. $msg->addParam(new xmlrpcval("create", "string"));
  18. $msg->addParam(new xmlrpcval($arrayVal, "struct"));
  19.  
  20. $resp = $client->send($msg);
  21.  
  22. if ($resp->faultCode())
  23.  
  24. echo 'Error: '.$resp->faultString();
  25.  
  26. else
  27.  
  28. echo 'Partner '.$resp->value()->scalarval().' created !';
  29.  
  30. ?>

URL: http://doc.openerp.com/developer/6_22_XML-RPC_web_services/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.