简体   繁体   English

使用python肥皂水使用用php编写的soap webservice,发生SAXParseException错误

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

I Use the following code to use a soap webservice written in PHP 我使用以下代码来使用用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)

It comes out the following error: 出现以下错误:

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

I'm new to suds and sopa webservice,I don't know what the error means, can someone can give me some advices 我是Sud和Sopa Web服务的新手,我不知道错误的含义,有人可以给我一些建议吗

You'll need this line to debug that: 您将需要以下行来进行调试:

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

Sample output: 样本输出:

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

Apparently even the maintained suds-jurko fork doesn't throw an error when using a login with insufficient rights. 显然,当使用权限不足的登录名时,即使维护的suds-jurko分支也不会引发错误。

Typically, this means the server is returning data, but it is not valid XML. 通常,这意味着服务器正在返回数据,但是它不是有效的XML。 It's likely a server problem. 这可能是服务器问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM