如何修复"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) 的输出与此页面上显示的内容类似。

您链接的文档说:

需要请求者 ID 才能指定发出请求的人员。

您的requestDictionary有一个请求者 ID 项目:

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

你的错误是说

缺少元素值(GetPostageLabel.LabelRequest.Value(

我认为您缺少请求者 ID 的值。

相关内容

最新更新