我想使用的xmlrpclib蟒蛇的lib做XMP-RPC,但我越來越XML-RPC客戶端蟒提高xml.parsers.expat.ExpatError例外
xml.parsers.expat.ExpatError: XML or text declaration not at start of entity: line 1, column 1
下面是參數的字典:
{'cliente_chave': 'hUi238sh328sjk37Hms8Kisjeg9',
'cliente_codigo': 164,
'imovel_bairro': u'Renascen\xe7a',
'imovel_banheiros': u'5',
'imovel_cidade': u'S\xe3o Lu\xeds - MA',
'imovel_codigo_imobiliaria': u'757',
'imovel_descricao': u'\n\t\t\t\n\t\t\tCasa em otima localiza\xe7\xe3o ideal tanto para empresas quanto para moradia tendo:\r\nTerra\xe7o\r\nSala Ampla para 03 ambientes\r\nLavabo\r\nHall\r\n03 su\xedtes\r\nEscritorio\r\nCozinha\r\nQuintaL\r\n\xc1rea de Servi\xe7o\r\nDCE\r\nGaragem coberta para 02 carros\r\nPort\xe3o eletronico\r\nCisterna\r\nNascente',
'imovel_estado': 'MA',
'imovel_negociacao': 'venda',
'imovel_novo': False,
'imovel_quartos': u'3',
'imovel_subtipo': u'padr\xe3o',
'imovel_suites': u'3',
'imovel_tipo': u'casa',
'imovel_vagas': u'2',
'imovel_valor': u' 480.000,00',
'url': 'http://www.estiloma.com.br/imoveis/para-venda/em-sao-luis/no-bairro-renascenca/casa-padrao/id-774.html'}
這裏是回溯到異常:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/Twisted-12.2.0-py2.7-macosx-10.8-intel.egg/twisted/internet/defer.py", line 551, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/Users/bslima/Documents/Aptana Studio 3 Workspace/aqueleimovel/aqueleimovel/pipelines.py", line 31, in process_item
result = server.salvar_imovel(dict(item))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1224, in __call__
return self.__send(self.__name, args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1575, in __request
verbose=self.__verbose
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1297, in single_request
return self.parse_response(response)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1467, in parse_response
p.feed(data)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 557, in feed
self._parser.Parse(data, 0)
xml.parsers.expat.ExpatError: XML or text declaration not at start of entity: line 1, column 1
我只使用UTF-8字符串
,我已經TR如果沒有運氣,可以編碼或解碼爲UTF-8。 我也嘗試谷歌它,但沒有sucsess。有人看到了嗎?
哇,這裏的客戶端代碼:
server = ServerProxy(uri=settings.RPC_SERVER, verbose=True)
server.salvar_imovel(item)
感謝提前的幫助。
正如我評論,ExpatError是在響應對象。由於
我注意到在回溯中,問題出在響應中,而不是在請求中。我會調查迴應,看看發生了什麼。謝謝@danodonovan – bslima 2013-03-03 22:53:10