0

I'm trying to access a soap service with WSDL:

http://taqm.epa.gov.tw/taqm/DataService.asmx?WSDL

Using pysimplesoap

#!/usr/bin/python

from codecs import Codec

from pysimplesoap.client import SoapClient
url = 'http://taqm.epa.gov.tw/taqm/DataService.asmx?WSDL'
client = SoapClient(wsdl=url,trace=False)

response = client.SiteList2('xml')
result = response['SiteList2Result']

When I try to print the result, it says "UnicodeEncodeError: 'ascii' codec can't encode characters in position 49-50: ordinal not in range(128)".

I'm guessing the response has traditional Chinese big5 encoding (or perhaps utf-8) in there.

Response is a dict, when printing it directly it shows:

{'SiteList2Result': u'<NewDataSet><Table><SITE_CODE>1</SITE_CODE><SITE>\u57fa\u9686</SITE><HSCITY>\u57fa\u9686\u5e02</HSCITY><DISTRICT>\u4fe1 \u7fa9 \u5340</DISTRICT>...

Why is it using the ascii codec and what is it doing? How do I solve it?

Aliaksandr Belik
  • 12,725
  • 6
  • 64
  • 90
huggie
  • 17,587
  • 27
  • 82
  • 139
  • A quick google search shows numerous bugs in pysimplesoap's unicode handling, eg - http://code.google.com/p/pysimplesoap/issues/detail?id=15 – jordanm Jun 22 '12 at 04:23
  • Well I think my question is not really pysimplesoap specific. I also tried suds and I can't get it to work. =/ – huggie Jun 22 '12 at 04:28

0 Answers0