Suds:响应中未找到类型
我很难让基于 suds 的 python SOAP 客户端解析响应:客户端构建正确并且解析 WSDL 很好。据我所知,WSDL 中没有导入,因此这看起来不像典型的 ImportDoctor
问题。
WSDL 中的相关位:
<xsd:complexType name="getFontsRequest">
<xsd:sequence>
<xsd:element name="UserID" type="xsd:int" maxOccurs="1" minOccurs="1"></xsd:element>
<xsd:element name="TAWSAccessKey" type="xsd:string" maxOccurs="1" minOccurs="1"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="getFontsResponse">
<xsd:sequence>
<xsd:element name="UserID" type="xsd:int"></xsd:element>
<xsd:element name="Status" type="xsd:string"></xsd:element>
<xsd:element name="Fonts" type="tns:FontType[]"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FontType">
<xsd:sequence>
<xsd:element name="ID" type="xsd:int"></xsd:element>
<xsd:element name="Name" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
我的代码:
self.soap_client = Client(settings.WSDL_URL)
self.factory = self.soap_client.factory
self.service = self.soap_client.service
# ...
getFontsRequest = self.factory.create('getFontsRequest')
getFontsRequest.UserID = settings.WS_UID
getFontsRequest.TAWSAccessKey = settings.WS_KEY
self.service.getFonts(getFontsRequest)
最后一行抛出此异常:
...
File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/suds/xsd/sxbasic.py", line 63, in resolve
raise TypeNotFound(qref)
TypeNotFound: Type not found: '(FontType[], http://www.type-applications.com/character_set/, )'
我的理解是,Web 服务返回一个 FontType
对象数组(即 FontType[]
),如下所示在 getFontResponse
方法中指定,但未定义 FontType[]
类型,仅描述 FontType
。
任何解决此问题的帮助将不胜感激。
I'm having a hard time getting a python SOAP client based on suds to parse a response: the client is constructed correctly and parses the WSDL just fine. As far as I can see there are no imports in the WSDL, so this doesn't seem like a typical ImportDoctor
issue.
Relevant bits from the WSDL:
<xsd:complexType name="getFontsRequest">
<xsd:sequence>
<xsd:element name="UserID" type="xsd:int" maxOccurs="1" minOccurs="1"></xsd:element>
<xsd:element name="TAWSAccessKey" type="xsd:string" maxOccurs="1" minOccurs="1"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="getFontsResponse">
<xsd:sequence>
<xsd:element name="UserID" type="xsd:int"></xsd:element>
<xsd:element name="Status" type="xsd:string"></xsd:element>
<xsd:element name="Fonts" type="tns:FontType[]"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="FontType">
<xsd:sequence>
<xsd:element name="ID" type="xsd:int"></xsd:element>
<xsd:element name="Name" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
My Code:
self.soap_client = Client(settings.WSDL_URL)
self.factory = self.soap_client.factory
self.service = self.soap_client.service
# ...
getFontsRequest = self.factory.create('getFontsRequest')
getFontsRequest.UserID = settings.WS_UID
getFontsRequest.TAWSAccessKey = settings.WS_KEY
self.service.getFonts(getFontsRequest)
The last line throws this exception:
...
File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/suds/xsd/sxbasic.py", line 63, in resolve
raise TypeNotFound(qref)
TypeNotFound: Type not found: '(FontType[], http://www.type-applications.com/character_set/, )'
My understanding is that the webservice returns an array of FontType
objects (i.e. FontType[]
), as specified in the getFontResponse
method, but fails to define the FontType[]
type, and merely describes FontType
.
Any help to resolve this would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能是
ImportDoctor
的工作。令人惊讶的是,遇到损坏的 WSDL 是很常见的。试试这个:
This might be a job for the
ImportDoctor
. It's surprisingly common to run across broken WSDLs.Try this:
通过联系 WSDL 提供商并要求他修复(损坏的)WSDL,该问题已得到解决。不幸的是,我不知道这个问题有任何基于代码的解决方案。
This issue has been resolved by contacting the WSDL provider and asking him to fix the (broken) WSDL. Unfortunately I'm unaware of any code-based solutions to this issue.