Cp1251-symbols in SOAP request

P

Pelmen

in short*** Outgoing SOAP
******************************************************
<?xml version="1.0" encoding="cp1251"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"<SOAP-ENV:Body>
<ns1:ÐомерДок xmlns:ns1="urn:Server" SOAP-ENC:root="1">
</ns1:ÐомерДок>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
************************************************************************
Traceback (most recent call last):
File "<pyshell#62>", line 1, in -toplevel-
doc.invoke('ÐомерДок'.decode('cp1251'), ())
File "C:\Python24\lib\site-packages\SOAPpy\Client.py", line 322, in
invoke
return self.__call(method, args, {})
File "C:\Python24\lib\site-packages\SOAPpy\Client.py", line 364, in
__call
config = self.config)
File "C:\Python24\lib\site-packages\SOAPpy\Client.py", line 196, in
call
r.endheaders()
File "C:\Python24\lib\httplib.py", line 795, in endheaders
self._send_output()
File "C:\Python24\lib\httplib.py", line 676, in _send_output
self.send(msg)
File "C:\Python24\lib\httplib.py", line 655, in send
self.sock.sendall(str)
File "<string>", line 1, in sendall
UnicodeEncodeError: 'ascii' codec can't encode characters in position
161-168: ordinal not in range(128)

How can i force this problem.
Thanks.
 
E

Erik Max Francis

Pelmen said:
UnicodeEncodeError: 'ascii' codec can't encode characters in position
161-168: ordinal not in range(128)

How can i force this problem.

The problem is that you're trying to write a Unicode string to a socket.
In order to do that properly, you have to encode it to a string properly.
 
P

Pelmen

as i understood, better way is base64 encoding on my side, and decoding
on server side?
 
J

Jarek Zgoda

Pelmen napisa³(a):
as i understood, better way is base64 encoding on my side, and decoding
on server side?

No, just encode the texts in what encoding the other side expects. If
this should be CP1251, not decoding would be enough.
 
J

Jarek Zgoda

Pelmen napisa³(a):
but socket will raise an exception if it'll be in cp1251

I am not a socket programming expert, but I didn't notice anything
strange when sending utf-8 or latin2 texts over sockets.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top