PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD] - How to convert Python/Java code in WD?
[WD] - How to convert Python/Java code in WD?
Iniciado por guest, 01,ene. 2016 08:09 - 2 respuestas
Publicado el 01,enero 2016 - 08:09
Hello,

Happy New Year to all members!

I am trying to communicate with Odoo (ERP) server from my WD app.

Odoo server uses XMLRPC to communicate with external clients.

Here is sample code in Python as well as Java:
Python
(ask https://demo.odoo.com for test Database)
import xmlrpclib info = xmlrpclib.ServerProxy('https://demo.odoo.com/start').start() url, db, username, password = info['host'], info['database'], info['user'], info['password']
Java
(ask https://demo.odoo.com for test Database)
final XmlRpcClient client = new XmlRpcClient(); final XmlRpcClientConfigImpl start_config = new XmlRpcClientConfigImpl(); start_config.setServerURL(new URL("https://demo.odoo.com/start")); final Map info = (Map)client.execute( start_config, "start", emptyList()); final String url = info.get("host"), db = info.get("database"), username = info.get("user"), password = info.get("password"); There is this note also:
Quote

Note



These examples use the Apache XML-RPC library



The examples do not include imports as these imports couldn't be pasted in the code.

Here is the code in WD that I am trying:
cMyRequest is httpRequest cMyResponse is httpResponse cMyRequest..URL = "https://demo3.odoo.com/" cMyRequest..ContentType = XMLRPDefault cMyRequest..User = "demo" cMyRequest..Password = "demo" cMyResponse = HTTPSend(cMyRequest) IF ErrorOccurred THEN Error(ErrorInfo(errFullDetails)) ELSE Info(cMyResponse..Content) END
Here is the online documentation link.

TIA

Yogi Yang
Publicado el 05,enero 2016 - 08:05
Hello Again,

This Python code is working perfectly but when I convert it to WD it is not working:
import xmlrpclib svr = 'abc.com:8069' db = 'test_erp' user = 'xyxyxyxy' pwd = 'xxxxxxxx' url = 'http://%s/xmlrpc/' % (svr) common_proxy = xmlrpclib.ServerProxy(url+'common') object_proxy = xmlrpclib.ServerProxy(url+'object') uid = common_proxy.login(db,user,pwd) print "Logged in as %s (uid:%d)" % (user, uid) SvrVersion = common_proxy.version() print SvrVersion Can someone help convert this in WD please...

TIA

Yogi Yang
Miembro registrado
102 mensajes
Publicado el 05,enero 2016 - 15:10
Yogi,

I don't see the port 8069 in your WD code. Could you try

cMyRequest..URL = "https://demo3.odoo.com:8069/"


--
http://arnoldconsult.de
WinDev 20 with Oracle, WinDevMobile Android Apps and Motorola Windows CE Mobile Barcode Scanners, Python 3 with Oracle and MySQL