Python使用suds调用webservice报错解决方法:AttributeError: 'Document' object has no attribute 'set'
2018-08-03 14:22
696 查看
使用python的suds包调用webservice服务接口,报错:AttributeError: 'Document' object has no attribute 'set'
调用服务接口代码:
#coding=utf-8 from suds.client import Client client = Client('http://port.patentstar.cn/bns/PtDataSvc.asmx?wsdl') print client pt = client.factory.create('PatentDataType') res = client.service.GetPatentData('DE10327589B4',pt.PDFFileUrl) print res
WSDL服务结构:
报错信息:
解决方法:
通过上图错误信息,错误指定到了appender.py 中的append函数 (此函数注释是我自己更改的)
以下是报暴出错误,的函数:
通过,对该函数分析,如果传过来的参数以_下止划线开头,会进行一个特列处理。
服务接口函数,两个参数都是以下划线开头。
报错的行为:parent.set(attr,value)
我们服务接口,参数名都是以下划线开头。于是分析之后,将关于处理下划线的代码行注释掉。
更改了suds,包中的文件后,重新调用服务接口。
结果如下:成功返回正确结果
至此,问题解决了,问题原因,应该是suds包的作者,没有考虑到其它服务接口,参数以下划线开头。
因为在python中下划线开头的变量,有特殊意义,是私有的。
以上是个人理解,如果个位大神,分析出有其它原因,分享一下。多谢谢。
相关文章推荐
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- python错误:AttributeError: 'module' object has no attribute 'setdefaultencoding'问题的解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- python调用对象属性出错:AttributeError: 'function' object has no attribute '_name_'
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- python错误:AttributeError: 'module' object has no attribute 'setdefaultencoding'问题的解决方法
- 【python学习笔记(2)】脚本报错"AttributeError: 'module' object has no attribute 'xxx'"解决方法
- java使用axis调用webservice时出现Connection reset by peer: socket write error的一种解决方法
- AttributeError: 'module' object has no attribute 的解决方法
- 转 Exception exceptions.AttributeError: "'NoneType' object has no attribute 'population'" 错误解决
- django view.py error 'QuerySet' object has no attribute 'save' 解决方法
- python 错误AttributeError: 'module' object has no attribute 'AF_INET'