我无法将此XML转换为相关的python字典soap请求以传递到Zeep.Client.service。下面的XML来自:
https://psix.uscg.mil/XML/PSIXData.asmx?op=getVesselSummaryXMLString
POST /XML/PSIXData.asmx HTTP/1.1
Host: psix.uscg.mil
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<getVesselSummaryXMLString xmlns="http://cgmix.uscg.mil">
<VesselID>string</VesselID>
<VesselName>string</VesselName>
<CallSign>string</CallSign>
<VIN>string</VIN>
<HIN>string</HIN>
<Flag>string</Flag>
<Service>string</Service>
<BuildYear>string</BuildYear>
</getVesselSummaryXMLString>
</soap12:Body>
</soap12:Envelope>
最后,我想用下面的代码向soap服务器发送一个请求,使用python字典作为“请求数据”,而不是上面的XML,我只是不确定需要哪个字典
url = 'https://cgmix.uscg.mil/xml/PSIXData.asmx?WSDL'
wsdl = url
client = zeep.Client(wsdl)
r = client.service.getVesselSummaryXMLString(request_data)
您可以使用以下方法检查wsdl方法:
从上面我们可以看到
getVesselSummaryXMLString
方法只接受字符串参数:因此,您可以将其简单地称为传递字符串参数,就像函数调用一样:
如果您想发送词典,那么您需要按照以下步骤准备词典:
希望这能回答这个问题
相关问题 更多 >
编程相关推荐