finalswordman
New Member
I am working to implement a Soap Service call in Python. There has a same Soap Service call in PHP, and it's success. What i need to do is call the same Soap Service through Python method.Below is piece of code how PHP call this Soap Service:\[code\]// otherwise, create a new account$response = $SoapClient->CreateAndLinkUser(array( 'tokenId' => base64_decode($Token), 'genomeId' => GLOBALS_GENOME_ID, ));\[/code\]I wrote below codes in Python to make simulate the same Soap Service Call:\[code\]import sudsprint sys.getdefaultencoding()print isinstance(userToken, unicode)print userTokenuserToken = base64.b64decode(userToken)print userTokenprint isinstance(userToken, unicode)client = suds.client.Client(GLOBALS_SOAP_SERVICE)client.service.CreateAndLinkUser( userToken, GLOBALS_GENOME_ID )\[/code\]Unfortunately, I will get below output and encounter a error.\[code\]utf-8Truel5fJSWTFoU+oMtggHIhsQQ==???Id?O?2? ?lAFalse\[/code\]\[code\] File "build\bdist.win32\egg\suds\client.py", line 542, in __call__ File "build\bdist.win32\egg\suds\client.py", line 595, in invoke File "build\bdist.win32\egg\suds\bindings\binding.py", line 120, in get_message File "build\bdist.win32\egg\suds\bindings\document.py", line 63, in bodycontent File "build\bdist.win32\egg\suds\bindings\document.py", line 105, in mkparam File "build\bdist.win32\egg\suds\bindings\binding.py", line 287, in mkparam File "build\bdist.win32\egg\suds\mx\core.py", line 62, in process File "build\bdist.win32\egg\suds\mx\core.py", line 75, in append File "build\bdist.win32\egg\suds\mx\appender.py", line 102, in append File "build\bdist.win32\egg\suds\mx\appender.py", line 198, in append File "build\bdist.win32\egg\suds\sax\element.py", line 251, in setText File "build\bdist.win32\egg\suds\sax\text.py", line 43, in __new__ UnicodeDecodeError: 'utf8' codec can't decode byte 0x84 in position 3: unexpected code byte\[/code\]As you see, the userToken string is unicode format before call base64.b64decode function, and it will not be a unicode format after that. And the decode string will cause exceptions when 'utf8' codec try to decode it. I am not too experience to call Soap service in Python. Can please help me to find the reason. And I am using Python 2.4. Thanks.