[英]Suds can't parse new wsdl file
I have a Python script that work with some third-party software through SOAP interface using suds 0.4.1-3.el6. 我有一个Python脚本,可以使用suds 0.4.1-3.el6通过SOAP接口与某些第三方软件一起使用。
Everything worked until a recent update of the software. 一切正常,直到最近对该软件进行了更新。 Now all scripts like: 现在所有脚本如下:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
#
import logging
from suds import WebFault
from suds.client import Client
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
client = Client("http://localhost:80/admin/soap/api3.wsdl")
#print client.location
#client.location = 'http://localhost:34012/'
print client
ends with: 以。。结束:
Traceback (most recent call last):
File "print.py", line 18, in <module>
client = Client("http://localhost:80/admin/soap/api3.wsdl")
File "/usr/lib/python2.6/site-packages/suds/client.py", line 119, in __init__
sd = ServiceDefinition(self.wsdl, s)
File "/usr/lib/python2.6/site-packages/suds/servicedefinition.py", line 58, in __init__
self.paramtypes()
File "/usr/lib/python2.6/site-packages/suds/servicedefinition.py", line 137, in paramtypes
item = (pd[1], pd[1].resolve())
File "/usr/lib/python2.6/site-packages/suds/xsd/sxbasic.py", line 63, in resolve
raise TypeNotFound(qref)
suds.TypeNotFound: Type not found: '(soapDiscountAddons, http://www.w3.org/2001/XMLSchema, )'
Software support said "our WSDL file is fine, ask suds developer", so I need help to investigate this problem. 软件支持说“我们的WSDL文件很好,请向suds开发人员咨询”,因此我需要帮助调查此问题。
Previous working files: 以前的工作文件:
https://dl.dropbox.com/u/4299326/py/20130225.wsdl/old/api3.wsdl https://dl.dropbox.com/u/4299326/py/20130225.wsdl/old/api3.wsdl
https://dl.dropbox.com/u/4299326/py/20130225.wsdl/old/encoding.xml https://dl.dropbox.com/u/4299326/py/20130225.wsdl/old/encoding.xml
New crashing files: 新的崩溃文件:
https://dl.dropbox.com/u/4299326/py/20130225.wsdl/new/api3.wsdl https://dl.dropbox.com/u/4299326/py/20130225.wsdl/new/api3.wsdl
https://dl.dropbox.com/u/4299326/py/20130225.wsdl/new/encoding.xml https://dl.dropbox.com/u/4299326/py/20130225.wsdl/new/encoding.xml
Software support said "our WSDL file is fine, ask suds developer" 软件支持人员说:“我们的WSDL文件很好,请向suds开发人员咨询”
I don't think that's correct. 我认为那是不对的。 The Type not found: '(soapDiscountAddons, http://www.w3.org/2001/XMLSchema, )'
message suds is showing is correct. Type not found: '(soapDiscountAddons, http://www.w3.org/2001/XMLSchema, )'
消息提示正确。
By looking at your WSDL, the soapDiscountAddons
is in the urn:api3
namespace so you need to mention that when you use it. 通过查看您的WSDL, soapDiscountAddons
位于urn:api3
名称空间中,因此您在使用它时需要提及。 The problem is here: 问题在这里:
<!-- operation response element -->
<element name="getDiscountAddonsResponse">
<complexType>
<sequence>
<element name="ret" type="soapDiscountAddons" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
<!-- operation request element -->
<element name="insupdDiscountAddon">
<complexType>
<sequence>
<element name="val" type="soapDiscountAddons" minOccurs="1" maxOccurs="1"/>
</sequence>
</complexType>
</element>
Because you didn't prefix the type, the current namespace is used which is http://www.w3.org/2001/XMLSchema
, not urn:api3
. 因为没有为类型添加前缀,所以使用的是当前名称空间,即http://www.w3.org/2001/XMLSchema
,而不是urn:api3
。 Instead of looking for soapDiscountAddons@urn:api3
where the type is, suds is trying to find a soapDiscountAddons@http://www.w3.org/2001/XMLSchema
element which of course doesn't exist. soapDiscountAddons@urn:api3
寻找类型所在的soapDiscountAddons@urn:api3
,而是尝试查找soapDiscountAddons@http://www.w3.org/2001/XMLSchema
元素,该元素当然不存在。
This should fix it: 这应该解决它:
<element name="getDiscountAddonsResponse">
<complexType>
<sequence>
<element name="ret" type="lbapi:soapDiscountAddons" minOccurs="1" maxOccurs="unbounded"/>
<!-- ^^^^^ you are missing this -->
</sequence>
</complexType>
</element>
<!-- operation request element -->
<element name="insupdDiscountAddon">
<complexType>
<sequence>
<element name="val" type="lbapi:soapDiscountAddons" minOccurs="1" maxOccurs="1"/>
<!-- ^^^^^ you are missing this -->
</sequence>
</complexType>
</element>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.