How to fix "zeep.exceptions.ValidationError: Missing element Value"

How to fix "zeep.exceptions.ValidationError: Missing element Value"

我正在集成 Endicia SOAP,但出现此错误:

"Missing element %s" % (self.name), path=render_path)
zeep.exceptions.ValidationError: Missing element
Value (GetPostageLabel.LabelRequest.Value)

这是我的代码:

import xml.etree.ElementTree as ET
from zeep import Client, Settings, xsd
from zeep.exceptions import Fault, TransportError, XMLSyntaxError

# Set Connection
settings = Settings(strict=False, xml_huge_tree=True)
client = Client(
'https://elstestserver.endicia.com/LabelService/EwsLabelService.asmx?wsdl',
settings=settings)

# Set label request dictionary
requestDictionary = {
    "MailClass": 'Priority',
    "WeightOz": 16,
    "RequesterID": '',
    "AccountID": '',
    "PassPhrase": '',
    "PartnerCustomerID": '100',
    "PartnerTransactionID": '200',
    "ToName": 'Margaret D Norris',
    "ToAddress1": '2461  Romano Street',
    "ToCity": 'Cambridge',
    "ToState": 'MA',
    "ToPostalCode": '02141',
    "FromCompany": 'Camilla R Goforth',
    "FromName": 'Camilla R Goforth',
    "ReturnAddress1": '1670  Oliverio Drive',
    "FromCity": 'Satanta',
    "FromState": 'KS',
    "FromPostalCode": '67870',
    "CostCenter":'0'
}



# Try operation
try:
    response = client.service.GetPostageLabel(LabelRequest=requestDictionary)
    print(response)


except Fault as error:
    print(ET.tostring(error.detail))


有人能帮忙吗?

我试过更改输入数据结构,但无济于事 我希望 response = client.service.GetPostageLabel(LabelRequest=requestDictionary)print(response) 的输出类似于 this page.

上显示的内容

您链接的文档说:

RequesterID is required to specify who is making the request.

您的 requestDictionary 有一个 RequesterID 的项目:

...
"RequesterID": '',
...

你的错误是

Missing element Value (GetPostageLabel.LabelRequest.Value)

我认为您缺少 RequesterID 的值。