mvantellingen / python-zeep

A Python SOAP client
http://docs.python-zeep.org
Other
1.87k stars 579 forks source link

How to add attributes in the Body elements? #1335

Closed johnshang2020 closed 1 year ago

johnshang2020 commented 1 year ago

How to add wd:Add_Only="false" in the Zeep client in below example. It is part of body elements

Ready appreciated if someone can point me to the right direction

<?xml version="1.0" encoding="UTF-8"?> <env:Envelope     xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"     xmlns:xsd="http://www.w3.org/2001/XMLSchema">     <env:Body>         <wd:Put_Purchase_Item_Request             xmlns:wd="urn:com.workday/bsvc"             wd:Add_Only="false"             wd:version="v38.0">             <wd:Purchase_Item_Reference>                 <wd:ID wd:type="Purchase_Item_ID">30000014</wd:ID>             </wd:Purchase_Item_Reference>         </wd:Put_Purchase_Item_Request>     </env:Body> </env:Envelope>

johnshang2020 commented 1 year ago

It pretty straightforward to deal with first required object, but not sure how to add "wd:Add_Only="false"" attributes?

request_dict = { 'ID': { 'type': 'Purchase_Item_ID', '_value_1': 30000014 } }

try : response= client.service.Put_Purchase_Item(Purchase_Item_Reference=request_dict ) except Exception: pass

johnshang2020 commented 1 year ago

Found solution as below

client.service.Put_Purchase_Item(Purchase_Item_Reference=request_dict, Add_Only='false' )

johnshang2020 commented 1 year ago

Resloved