我正嘗試使用Python/SUDS連接到Web服務。Python Suds Soap客戶端錯誤
我在單個文件中有以下代碼,並且我能夠成功連接並收到響應。
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:'
我想在將從按鈕單擊事件中調用的Python客戶端應用程序中使用此代碼。 我試圖實現這一點,我可以打印出客戶端,但是當我撥打網絡服務電話(print self.client.service.AddPerson(Person)
)時,出現以下錯誤。
unsupported operand type(s) for +: 'NoneType' and 'str'
我該如何解決這個錯誤?