【问题标题】:How to fix "zeep.exceptions.ValidationError: Missing element Value"如何修复“zeep.exceptions.ValidationError:缺少元素值”
【发布时间】:2019-06-19 09:42:35
【问题描述】:

我正在集成 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 上显示的一样。

【问题讨论】:

    标签: python soap wsdl zeep


    【解决方案1】:

    您链接的文档说:

    RequesterID 用于指定提出请求的人。

    您的 requestDictionary 有一个 RequesterID 项目:

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

    你的错误是说

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

    我认为您缺少 RequesterID 的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-22
      • 2011-04-15
      • 2019-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-24
      • 2013-11-01
      相关资源
      最近更新 更多