1

我使用下面的代码来使用一个用 PHP 编写的soap webservice

#!/usr/local/bin/python

import logging
logging.basicConfig(levee = logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)
import urllib2
from suds.client import Client
from suds.sax.element import Element


url = 'a sopa webservice url'
client = Client(url)

它出现以下错误:

Traceback (most recent call last):
File "./auth.py", line 13, in <module>
   client = Client(url)
File "build/bdist.linux-x86_64/egg/suds/client.py", line 112, in __init__
File "build/bdist.linux-x86_64/egg/suds/reader.py", line 152, in open
File "build/bdist.linux-x86_64/egg/suds/wsdl.py", line 136, in __init__
File "build/bdist.linux-x86_64/egg/suds/reader.py", line 79, in open
File "build/bdist.linux-x86_64/egg/suds/reader.py", line 101, in download
File "build/bdist.linux-x86_64/egg/suds/sax/parser.py", line 136, in parse
File "/usr/local/lib/python2.7/xml/sax/expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/local/lib/python2.7/xml/sax/xmlreader.py", line 125, in parse
self.close()
File "/usr/local/lib/python2.7/xml/sax/expatreader.py", line 220, in close
self.feed("", isFinal = 1)
File "/usr/local/lib/python2.7/xml/sax/expatreader.py", line 214, in feed
self._err_handler.fatalError(exc)
File "/usr/local/lib/python2.7/xml/sax/handler.py", line 38, in fatalError
raise exception
xml.sax._exceptions.SAXParseException: <unknown>:1:0: no element found

我是suds和sopa webservice的新手,我不知道错误是什么意思,谁能给我一些建议

4

2 回答 2

1

你需要这一行来调试它:

logging.getLogger('suds.transport').setLevel(logging.DEBUG)

样本输出:

DEBUG:suds.transport.http:received:
CODE: 200
HEADERS: {'content-length': '16', ..., 'connection': 'close', 'x-sharepointhealthscore': '0', 'cache-control': 'private, max-age=0', 'date': 'Tue, 25 Mar 2014 11:24:51 GMT', 'www-authenticate': 'NTLM'}
MESSAGE:
401 UNAUTHORIZED
DEBUG:suds.client:HTTP succeeded:
401 UNAUTHORIZED
ERROR:suds.client:<suds.sax.document.Document instance at 0x02C21AF8>
Traceback (most recent call last):
  File "ExpiryMonitor.py", line 99, in <module>
    if __name__ == '__main__': main()
  File "ExpiryMonitor.py", line 66, in main
    items = c_lists.service.GetListItems(LIST_ID, VIEW_ID)
  File "build\bdist.win32\egg\suds\client.py", line 521, in __call__
  File "build\bdist.win32\egg\suds\client.py", line 581, in invoke
  File "build\bdist.win32\egg\suds\client.py", line 621, in send
  File "build\bdist.win32\egg\suds\client.py", line 661, in process_reply
  File "build\bdist.win32\egg\suds\client.py", line 832, in _parse
  File "build\bdist.win32\egg\suds\sax\parser.py", line 133, in parse
  File "C:\python27\lib\xml\sax\expatreader.py", line 107, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "C:\python27\lib\xml\sax\xmlreader.py", line 123, in parse
    self.feed(buffer)
  File "C:\python27\lib\xml\sax\expatreader.py", line 211, in feed
    self._err_handler.fatalError(exc)
  File "C:\python27\lib\xml\sax\handler.py", line 38, in fatalError
    raise exception
xml.sax._exceptions.SAXParseException: <unknown>:1:0: syntax error

显然,即使是维护的 suds-jurko fork在使用权限不足的登录名时也不会引发错误。

于 2014-03-25T13:13:37.723 回答
0

通常,这意味着服务器正在返回数据,但它不是有效的 XML。很可能是服务器问题。

于 2013-09-19T15:49:20.810 回答