[英]How to create a soap-enc:Array parameter with python zeep?
I have to construct a SOUP method Agw_typeGenerarDespachoIn from wsdl我必须从wsdl构造一个 SOUP 方法 Agw_typeGenearDespachoIn
<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>
I construct the param guias of type soap-enc:Array我构造了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))
I get return我得到回报
'`list`' object has no attribute '`_xsd_name`'
If i try with other value for param guias like如果我尝试为 param guias 使用其他值,例如
guia = dict(item='98516000056')
i get the return error我收到返回错误
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: {}`
So i try with the sugered value "_value_1"所以我尝试使用 sugered 值“_value_1”
guia = dict(_value_1=['98516000056'])
And get the error并得到错误
Any element received object of type 'unicode', expected lxml.etree._Element or __builtin__.dict or zeep.xsd.valueobjects.AnyObject
I have tried different ways to build the soup-enc:Array parameter but I always get an error.我尝试了不同的方法来构建soup-enc:Array 参数,但我总是遇到错误。 You know how I can fix it.你知道我该如何解决它。 I appreciate all the help you can give me我感谢你能给我的所有帮助
My mistake in creating the array in the Agw_typeGenerarDespachoIn method of the Coordinadora transporter was to try to create the Array type.我在 Coordinadora 传输器的 Agw_typeGenearDespachoIn 方法中创建数组的错误是尝试创建数组类型。 Actually the type Array should be taken as a normal python array.实际上,类型 Array 应该被视为普通的python数组。
guias = []
String elements must be created that will be added to the array.必须创建将添加到数组中的字符串元素。
guias_type = client.get_element('ns1:string')
Finally, append elements string type to the array.最后,将元素字符串类型附加到数组。
for remesa in remesas:
guias.append(xsd.AnyObject(guias_type, remesa))
Put all params in the method将所有参数放入方法中
Agw_typeGenerarDespachoIn = factory.Agw_typeGenerarDespachoIn(guias=guias, # array Codigos de guia a las que se les va a generar un despacho (array de strings)
margen_izquierdo=float(0), # float Margen izquierdo para la generacion del PDF, en caso que el tipo impresion seleccionado genere un PDF
margen_superior=float(0), # float Margen superior para la generacion del PDF, en caso que el tipo impresion seleccionado genere un PDF
tipo_impresion=unicode('LASER'), # string Tipo de impresion que se desea obtener las opciones son (LASER, LASER_RESUMIDA, POS_PDF, POS_PLANO).
usuario=unicode(self.usuario), # string Usuario asignado. Ej: prefijo.usuario
clave=unicode(self.clave) # string Clave codificada con el algoritmo sha256.
)
print Agw_typeGenerarDespachoIn
response = client.service.Guias_generarDespacho(Agw_typeGenerarDespachoIn)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.