I need to send a SOAP message (with Python SUDS) with strings encoded in 'iso-8859-2'. Does anybody know how to do it?
SUDS raises the following exception when I invoke a method on a client with parameters encoded in 'iso-8859-2':
File "/home/bartek/myenv/lib/python2.5/site-packages/suds/sax/text.py", line 43, in __new__
result = super(Text, cls).__new__(cls, *args, **kwargs)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 10: ordinal not in range(128)
Text = Text.decode('iso-8859-2')
might be all you need, if Text starts out as an 8-bit string that was encoded with iso-8859-2. If it needs to be sent as a UTF-8 string or something, however, then you'd probably want to use
Text = Text.decode('utf-8')
If neither of those, then just play around with the decode()
and encode()
methods and the error handling methods used with them: http://docs.python.org/release/2.5/lib/string-methods.html
(Took out most of the stuff in my answer that wasn't really necessary, considering what the question states.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.