Python Suds Soap Client Error
Question: I am trying to connect to a web service using Python/SUDS.

I have the following code in a single file and I am able to connect
successfully and I receive a response.

    
    
    class Suds_Connect:
        def __init__(self, url, q_user, q_passwd):
    
            logging.basicConfig(level=logging.INFO)
            logging.getLogger('suds.client').setLevel(logging.DEBUG)
            try:
                # fix broken wsdl
                # add <s:import namespace="http://www.w3.org/2001/XMLSchema"/> to the wsdl
                imp = Import('http://www.w3.org/2001/XMLSchema',
                location='http://www.w3.org/2001/XMLSchema.xsd')
    
                wsdl_url = url
                self.client = Client(wsdl_url, doctor=ImportDoctor(imp))
                t = HttpAuthenticated()
    
    
                security = Security()
                token = UsernameToken(q_user,q_passwd)
                security.tokens.append(token)
                self.client.set_options(wsse=security)
    
    
    
            except Exception, e: 
                print "Unexpected error:", sys.exc_info()[0]
                print str(e)
                sys.exit()
    
    
    def CallWebMethod():
    
            try:
            print ' SUDS Client'
                print self.client
                Person= self.client.factory.create('ns0:Person')
    
    
                Person.name= 'bob'
                Person.age= '34'
                Person.address= '44, river lane'
                print self.client.service.AddPerson(Person)
    
            except WebFault, f:
                print str(f.fault)
            except Exception, e: 
                print str(e)
    
    if __name__ == '__main__':
        errors = 0
        sudsClient = Suds_Connect('url','user','password')
        sudsClient.CallWebMethod()
        print '\nFinished:'
    

I want to use this code in a Python client app that will be called from a
button click event. I have tried to implement this and I am able to print out
the client but when I make the web service call (`print
self.client.service.AddPerson(Person)`) I get the following error.

    
    
    unsupported operand type(s) for +: 'NoneType' and 'str'
    

How do I go about fixing this error?


Answer: Looks like webservice call returns None. Additional information is required to
identify what went wrong.

First of all - enable suds logging by adding before calling Suds_Connect. This
should provide you information about what's going on in suds under the hood.

    
    
    import logging
    logging.basicConfig(level=logging.DEBUG) 
    

Another thing to try for getting more debug information - please try the
following instead of `print self.client.service.AddPerson(Person)`

    
    
    result = self.client.service.AddPerson(Person)
    print str(result)
    

Also it would be helpful to get full stack trace for exception - which line it
happens at and what is the call stack. Please try to comment out exception
handling for `except Exception, e:` case and post here the exception you'll
get.

