【发布时间】:2020-01-04 05:12:37
【问题描述】:
我必须从wsdl 构造一个 SOUP 方法 Agw_typeGenerarDespachoIn
<xsd:complexType name="Agw_typeGenerarDespachoIn">
<xsd:all>
<xsd:element name="guias" type="soap-enc:Array"/>
<xsd:element name="margen_izquierdo" type="xsd:float"/>
<xsd:element name="margen_superior" type="xsd:float"/>
<xsd:element name="tipo_impresion" type="xsd:string"/>
<xsd:element name="usuario" type="xsd:string"/>
<xsd:element name="clave" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
我构造了soap-enc:Array 类型的参数guias
array_type = self.client.get_type('ns1:Array')
guias = array_type()
values = xsd.AnyObject(array_type, array_type(_attr_1={'guias': '98516000037'}))
Agw_typeGenerarDespachoIn = self.factory.Agw_typeGenerarDespachoIn(guias=values,
margen_izquierdo=float(0),
margen_superior=float(0),
tipo_impresion=unicode('LASER'),
usuario=unicode(self.usuario),
clave=unicode(self.clave))
我得到回报
'`list`' object has no attribute '`_xsd_name`'
如果我尝试使用 param guias 的其他值,例如
guia = dict(item='98516000056')
我收到返回错误
TypeError: {http://schemas.xmlsoap.org/soap/encoding/}Array() got an unexpected keyword argument 'item'. Signature: `_value_1: ANY[], arrayType: xsd:string, offset: {http://schemas.xmlsoap.org/soap/encoding/}arrayCoordinate, id: xsd:ID, href: xsd:anyURI, _attr_1: {}`
所以我尝试使用 sugered 值“_value_1”
guia = dict(_value_1=['98516000056'])
并得到错误
Any element received object of type 'unicode', expected lxml.etree._Element or __builtin__.dict or zeep.xsd.valueobjects.AnyObject
我尝试了不同的方法来构建soup-enc:Array 参数,但总是出错。你知道我该如何解决它。感谢您给予我的所有帮助
【问题讨论】: