简体   繁体   English

使用Python和suds 0.4的SAXParseException?

[英]SAXParseException using Python and suds 0.4?

I have a simple Python script that uses Suds to pull data from a SOAP web service. 我有一个简单的Python脚本,它使用Suds从SOAP Web服务中提取数据。 It works perfectly on one machine, but when I move it to another that has an older version of Python (2.4.3), I get the following stack trace: 它在一台机器上完美运行,但当我将它移动到另一台具有较旧版本的Python(2.4.3)时,我得到以下堆栈跟踪:

>>> client = suds.client.Client(url, username='xxx', password='xxx', location=service_location, cache=None)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/home/etlsmart/lib/python2.4/site-packages/suds/client.py", line 112, in __init__
    self.wsdl = reader.open(url)
File "build/bdist.linux-i686/egg/suds/reader.py", line 152, in open
File "build/bdist.linux-i686/egg/suds/wsdl.py", line 136, in __init__
File "build/bdist.linux-i686/egg/suds/reader.py", line 79, in open
File "build/bdist.linux-i686/egg/suds/reader.py", line 101, in download
File "/home/etlsmart/lib/python2.4/site-packages/suds/sax/parser.py", line 136, in parse
    sax.parse(source)
File "/usr/lib/python2.4/site-packages/_xmlplus/sax/expatreader.py", line 109, in parse
    xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib/python2.4/site-packages/_xmlplus/sax/xmlreader.py", line 123, in parse
    self.feed(buffer)
File "/usr/lib/python2.4/site-packages/_xmlplus/sax/expatreader.py", line 220, in feed
    self._err_handler.fatalError(exc)
File "/usr/lib/python2.4/site-packages/_xmlplus/sax/handler.py", line 38, in fatalError
    raise exception
xml.sax._exceptions.SAXParseException: <unknown>:18:2: mismatched tag

I've looked at various related errors involving the cache, but that doesn't seem to be the issue. 我查看了涉及缓存的各种相关错误,但这似乎不是问题。 I've disabled the cache and /tmp/suds only contained a version file in any case. 我已禁用缓存,而/ tmp / suds在任何情况下都只包含一个版本文件。

Is this likely related to the Python version or is there something else obvious that I should try? 这可能与Python版本有关,还是有其他明显的东西我应该尝试?

I had the same problem. 我有同样的问题。 The server has answering HTML instead of SOAP. 服务器已回答HTML而不是SOAP。

The endpoint has responding with an HTML message of error, not an SOAP XML. 端点使用错误的HTML消息进行响应,而不是SOAP XML。 For some reason, SUDS says "I cannot parse this. Halp!" 出于某种原因,SUDS说“我无法解析这个。哼!” instead of "I cannot parse this answer: < answer here >", even with DEBUG log level. 而不是“我无法解析这个答案:<answer here>”,即使使用DEBUG日志级别也是如此。

Found that poking into suds.reader, using a debugger: 发现使用调试器进入suds.reader:

/usr/lib/python2.6/site-packages/suds/reader.py in download(self, url)
    100         content = ctx.document
    101         sax = Parser()
--> 102         return sax.parse(string=content)
    103 
    104     def cache(self):

Look at content and see if its an SOAP XML. 查看content并查看它是否为SOAP XML。

Good luck. 祝好运。

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

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