This issue is maybe somewhat releated to #145.
However the former issue has already been closed so I hope you don't mind if I open a new one.
I have currently the problem that arrays/sequences are sent empty to the server:
WSDL (partly):
<wsdl:message name="save_master_data">
<wsdl:part name="atk" type="xsd:string">
</wsdl:part>
<wsdl:part name="type" type="xsd:string">
</wsdl:part>
<wsdl:part name="data" type="tns:masterObjectDataArray">
</wsdl:part>
</wsdl:message>
<xs:complexType final="#all" name="masterObjectDataArray">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="item" nillable="true" type="tns:masterObjectData"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="masterObjectData">
<xs:sequence>
<xs:element name="id" type="xs:long"/>
<xs:element minOccurs="0" name="name" type="xs:string"/>
<xs:element name="alive" type="xs:boolean"/>
<xs:element minOccurs="0" name="custom" type="xs:string"/>
</xs:sequence>
</xs:complexType>
Method called:
objects = [
client.type_factory('ns0').masterObjectData(id=1, name="Object1", alive=true, custom=""),
client.type_factory('ns0').masterObjectData(id=2, name="Object2", alive=true, custom=""),
client.type_factory('ns0').masterObjectData(id=3, name="Object3", alive=true, custom="")
]
client.save_master_data("foo", "bar", objects)
Request beeing sent:
<soap-env:Envelope xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope">
<soap-env:Body>
<ns0:save_master_data xmlns:ns0="http://example">
<atk>foo</atk>
<type>bar</type>
<data/>
</ns0:save_master_data>
</soap-env:Body>
</soap-env:Envelope>
Python Debug (generation of objects seems to be successfull):
print(repr(objects))
#==>
[{
'id': 1,
'name': 'Object1',
'alive': True,
'custom': "" },
{
'id': 2,
'name': 'Object2',
'alive': True,
'custom': "" },
[...] ]
Expected (afaik):
<soap-env:Envelope xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope">
<soap-env:Body>
<ns0:save_master_data xmlns:ns0="http://example">
<atk>foo</atk>
<type>bar</type>
<data>
<masterObjectData>
<id>1</id>
<name>Object1</name>
<custom></custom>
</masterObjectData>
<masterObjectData>
<id>2</id>
<name>Object2</name>
<custom></custom>
</masterObjectData>
[...]
</data>
</ns0:save_master_data>
</soap-env:Body>
</soap-env:Envelope>
I'm having the same problem (with different WSDL).
Turns out, you need to pass factory.masterObjectDataArray(objects). I wonder if there's room for special handling of such array arguments in the library, because it's very counterintuitive right now.
Hi,
Thanks for the report. It is unfortunately missing an example script as explained in the documentation (see http://docs.python-zeep.org/en/master/reporting_bugs.html). This is also mentioned when you create the issue on github.
I realise this will result in extra work on your side, but I can really use the extra help.
Which version of zeep are you using? I' cant reproduce it so an example script is required here
Thanks for your response. I'll get you an example script tomorrow.
I'm having the same problem here 馃槥
This approach saved my life:
https://github.com/mvantellingen/python-zeep/issues/145#issuecomment-299317970
Instead of use this data structure:
'SomeData': [
{'SomeObject': {'code': '000'}},
{'SomeObject': {'code': '001'}}
]
Try this one:
'SomeData': {
'SomeObject': [{'code': '000'}, {'code': '001'}]
}
Hi,
I'm having the same problem. Populating values from Django into a dictionary and then iter over them into a formatted array. Zeep only takes the first item in the array
https://gist.github.com/wynandvdl/b8fb446f3dbacc749dec5c739fc62f2a
Here is the script I run for testing purposes
from zeep import Client
from lxml import etree
client = Client('http://integrator.eduprinters.co.za:16899/axis/services/DistributionWS?wsdl')
lineitem = []
items = '12345', 'test1'
for item in items:
line_type = client.get_type('ns2:ArrayOf_tns3_SalesOrderLineCreateRequest')
line = line_type({'itemCode': item})
lineitem.append(line)
node = client.create_message(client.service, 'salesOrderCreate', accountNumber='1234', salesOrderLineCreateRequests=lineitem)
print(etree.tostring(node, pretty_print=True))
The array generated looks correct
>>> lineitem
[{
'item': {
'itemCode': '12345'
}
}, {
'item': {
'itemCode': 'test1'
}
}]
I'm running Zeep 2.0.0
Here is the output
<ns0:Body>
<ns1:salesOrderCreateRequest>
<ns2:accountNumber>1234</ns2:accountNumber>
<ns2:accountPassword xsi:nil="true"/>
<ns2:carrierCode xsi:nil="true"/>
<ns2:contactId xsi:nil="true"/>
<ns2:customerContactId xsi:nil="true"/>
<ns2:customerReference xsi:nil="true"/>
<ns2:customerReferenceDate xsi:nil="true"/>
<ns2:deliveryAddress1 xsi:nil="true"/>
<ns2:deliveryAddress2 xsi:nil="true"/>
<ns2:deliveryAddress3 xsi:nil="true"/>
<ns2:deliveryAddress4 xsi:nil="true"/>
<ns2:deliveryAddress5 xsi:nil="true"/>
<ns2:deliveryAddress6 xsi:nil="true"/>
<ns2:deliveryName xsi:nil="true"/>
<ns2:emailAddress xsi:nil="true"/>
<ns2:entity xsi:nil="true"/>
<ns2:orderPriority xsi:nil="true"/>
<ns2:partialDelivery xsi:nil="true"/>
<ns2:salesOrderBillingCreateRequest xsi:nil="true"/>
<ns2:salesOrderLineCreateRequests>
<ns4:item>
<ns2:despatchDate xsi:nil="true"/>
<ns2:itemBarcode xsi:nil="true"/>
<ns2:itemCode>12345</ns2:itemCode>
<ns2:itemDescription xsi:nil="true"/>
<ns2:orderLineNumber xsi:nil="true"/>
<ns2:orderQuantity xsi:nil="true"/>
<ns2:salesOrderLineTextCreateRequests xsi:nil="true"/>
<ns2:unitPrice xsi:nil="true"/>
</ns4:item>
</ns2:salesOrderLineCreateRequests>
<ns2:salesOrderPaymentCreateRequest xsi:nil="true"/>
<ns2:sourceOfOrder xsi:nil="true"/>
<ns2:specialInstructions1 xsi:nil="true"/>
<ns2:specialInstructions2 xsi:nil="true"/>
<ns2:standardAccountNumber xsi:nil="true"/>
</ns1:salesOrderCreateRequest>
</ns0:Body>
@wynandvdl which zeep version are u using? I think this issue was fixed on version 2.0.0:
https://github.com/mvantellingen/python-zeep/blob/master/CHANGES
BTW, you can change your data structure to something like this:
https://github.com/mvantellingen/python-zeep/issues/435#issuecomment-301918382
Hi marquesds,
Seems I only needed the weekends rest.
I did the following and everything worked as it should.
for item in items:
line = {'itemCode': item}
lineitem.append(line)
lines = line_type(lineitem)
Thanks for the help.
Yeah the issue seems to be mainly that soap encodes arrays in a weird way. That's why you see a lot of times stuff like: 'results': ArrayOfStrings -> [string1, string2, ..].
It's mostly a documentation issue which i hope tol solve with #110
Closing this for now as it seems to be solved and I need some order in the issue list :-)
Most helpful comment
This approach saved my life:
https://github.com/mvantellingen/python-zeep/issues/145#issuecomment-299317970
Instead of use this data structure:
Try this one: