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

XML RPC - How do I logout / close / disconnect a connection ?

By
feriel bendimerad
on 7/23/14, 4:20 AM 2,265 views

Hello everyone , 

i'm working on a web service, on my program i create a connection :

XmlRpcClient xmlrpcLogin = new XmlRpcClient();  
        XmlRpcClientConfigImpl xmlrpcConfigLogin = new XmlRpcClientConfigImpl();  //instance de XmlRpcClient    
        xmlrpcConfigLogin.setEnabledForExtensions(true);  
        URL url=new URL("http",IP,8069,"/xmlrpc/common"); 

       xmlrpcConfigLogin.setServerURL(url); 

        xmlrpcLogin.setConfig(xmlrpcConfigLogin);   
        Vector<String> params = new Vector<String>();    
        params.add(DBname);
        params.add(Login); 
        params.add(DBpsw); 

        xmlrpcLogin.execute("login", params);

My question is : How can i logout  (disconnect )from this connection , i search  on the internet for the instuction but with no result 

Thanks for helping

Same question here : how do you disconnect the pipe?

Soriyath Straessle
on 11/11/14, 2:56 AM
1
shashank verma
On 11/11/14, 5:29 AM

Hello feriel bendimerad,

XMLRPC webservices in Odoo/OpenERP are in stateless form. Hence we do not require session logout.

Lets take a simple example to prove this :


import xmlrpclib
x=0
while x<3:
    
    x+=1
    print '------------Session {}------------'.format(x)
    #LOGIN DETAILS
    #ENTER YOUR LOGIN CREDENTIAL TO CONNECT

    val=raw_input('Enter username,password,database name seperated by commas : ').split(',') #seperate by commas is mandatory else wrong i/p
    username,password,database = val[0],val[1],val[2]
    sock_comm = xmlrpclib.ServerProxy('http://yourdomain/xmlrpc/common')

    uid = sock_comm.login(database,username,password)

    sock = xmlrpclib.ServerProxy('http://yourdomain/xmlrpc/object')
    
   
    so_ids = sock.execute(database,uid, password,'sale.order', 'search',[])
  
    print 'Total Sale Orders={}'.format(len(so_ids))
    if x==2:
        print 'This is your last attempt'
print '3 attempts over....Program Terminated!!!'

######################################
OUTPUT OF THE PROGRAM
------------Session 1------------
Enter username,password,database name seperated by commas : my_username,my_password,mydatabase1
Total Sale Orders=1
------------Session 2------------
Enter username,password,database name seperated by commas : my_username,my_password,mydatabase2
Total Sale Orders=39
This is your last attempt
------------Session 3------------
Enter username,password,database name seperated by commas : my_username,my_password,mydatabase3
Total Sale Orders=15
3 attempts over....Program Terminated!!!

##################################

So you can see i have accessed 3 different databases sale order records without session logout

 

 

Thank you for the answer. Does this mean that we have to login at each rpc call?

Soriyath Straessle
on 11/12/14, 4:08 AM

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

2 follower(s)

Stats

Asked: 7/23/14, 4:20 AM
Seen: 2265 times
Last updated: 3/16/15, 8:10 AM