Suds:在响应中找不到类型 [英] Suds: Type not found on response
问题描述
我很难获得基于 suds 的 python SOAP 客户端来解析响应:客户端构造正确并且解析 WSDL 就好了.就我所见,WSDL 中没有导入,因此这似乎不是典型的 ImportDoctor
问题.
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.
WSDL 中的相关部分:
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>
我的代码:
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/, )'
我的理解是,webservice 返回一个 FontType
对象数组(即 FontType[]
),如 getFontResponse
方法中所指定,但是没有定义FontType[]
类型,仅仅描述了FontType
.
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.
推荐答案
通过联系 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.
这篇关于Suds:在响应中找不到类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!