如何在Python中使用zeep格式化来自WSDL的xml请求

如何在Python中使用zeep格式化来自WSDL的xml请求,python,python-3.x,soap,zeep,Python,Python 3.x,Soap,Zeep,我有一个xml请求示例,它应该像这样发送到SOAP服务器: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.example.com" xmlns:bos="http://bos.example.com" xmlns:ser1="http://service.example.com"> <soapenv:Header/&g

我有一个xml请求示例,它应该像这样发送到SOAP服务器:

<soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ser="http://service.example.com" 
xmlns:bos="http://bos.example.com"
xmlns:ser1="http://service.example.com">
<soapenv:Header/>
<soapenv:Body>
<ser:UploadRequest ac="YY">
<ser:updateRecord>
<ser:employee ptc="xxx" lastname="Example" firstname="Employee" 
gender="F">
<bos:employment eID="testEmployee" doj="2000-01-17"/>
<bos:employment-status startDate="2000-01-17" status="active"/>
</ser:employee>
</ser:updateRecord>
</ser:UploadRequest>
</soapenv:Body>
</soapenv:Envelope>
我得到了这个错误

TypeError:{}UpdateRecord()获取了一个
意外的关键字参数“eID”。签名:`雇员:
{}雇员


我需要的是如何使用zeep格式化上述请求。

xml
包导入
parseString
参数

from xml.dom.minidom import parseString
然后按照下面的代码操作

result = parseString(xml).toprettyxml() # xml is your variable
print(result)
结果:

<?xml version="1.0" ?>
<employees>
  <employee>
    <Name>Leonardo DiCaprio</Name>
  </employee>
</employees>

莱昂纳多·迪卡普里奥
<?xml version="1.0" ?>
<employees>
  <employee>
    <Name>Leonardo DiCaprio</Name>
  </employee>
</employees>