0

I am new programing and I developed a small webservice in python using SOAPpy.

This webservice get some data from a sql Server and it returns in a list of tuples with this format [(a,b,c),(d,e,f),...] This is the server code:

class ws():
 def recoveruserdata(self,param1,param2):

    tupla_recover = ()
    l_recover = []

    ...
    cnxn = pyodbc.connect(con_string) 

    ...        
    cursor.execute(query)

    rows = cursor.fetchall()

    for row in rows:

        if row.id != ' ':
            tupla_recover = (row.id,row.date)                
            l_recover.append(tupla_recover)                
            print l_recover

    print "Len of lrecover ", len(l_recover)
    print "first element ",l_recover[0]
    return l_recover

 if __name__ == '__main__':    
     server = SOAPServer(("localhost", 8082))
     wsobj = ws()
     server.registerObject(wsobj)
     server.serve_forever()

The problem ocurrs when I try to consume the web service from a python client using SOAPpy too. I can get a list but it not contains the tuples as above, instead of it, you get a list of all individual elements with this format [a,b,c,d,e,f,....] This is the client code:

 from SOAPpy import SOAPProxy
 server = SOAPProxy("http://localhost:8082/")
 cliente = server.recoveruserdata(param1,param2)
 print cliente

My question is if, is it normal this behavior or am I doing something wrong?

I apreciate your help

  • 1
    Please post the code of what you have tried so far. – Ryan J. Smith Apr 23 '15 at 19:56
  • Don't use SOAPpy for new development. Even the readme for SOAPpy states that you should use `suds` instead. – jordanm Apr 23 '15 at 21:38
  • I think I found out part of the problem and it is not related with SOAPpy. The problem is related in how Python returns a list of tuples. In this case Python is returning a flatten list . Is it possible to avoid this behavior? – Sergio Álvarez Apr 24 '15 at 15:50

0 Answers0