簡體   English   中英

使用python肥皂水使用用php編寫的soap webservice,發生SAXParseException錯誤

[英]Using python suds to use soap webservice written in php, SAXParseException error occur

我使用以下代碼來使用用PHP編寫的Soap Web服務

#!/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

我是Sud和Sopa Web服務的新手,我不知道錯誤的含義,有人可以給我一些建議嗎

您將需要以下行來進行調試:

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分支也不會引發錯誤。

通常,這意味着服務器正在返回數據,但是它不是有效的XML。 這可能是服務器問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM