0

我正在尝试在 python 中调用“Get_Purchase_Orders”操作,并在收到响应时抛出以下错误

TypeError error in Get_Purchase_Orders : {urn:com.workday/bsvc}Bill_To_Address_ReferenceType() got an unexpected keyword argument 'Address_Reference'. Signature: `({Bill_To_Address_Reference: {urn:com.workday/bsvc}Unique_IdentifierObjectType} | {Address_Reference: {urn:com.workday/bsvc}Address_ReferenceType[]}) Unexpected error:  <class 'TypeError'>

WSDL 文件可在此处访问

我的发现:

Bill_To_Address_Data有两个相互排斥的元素 (Bill_To_Address_ReferenceAddress_Reference),这意味着只有两个元素中的一个是预期的(有选择Bill_To_Address_Reference Address_Reference,两个标签都在响应)。可以在此处查看示例 XML 。

xml块也可以在下面看到

<bsvc:Bill_To_Address_Data>
 <!-- You have a CHOICE of the next 2 items at this level -->
 <!-- Optional: -->
 <bsvc:Bill_To_Address_Reference bsvc:Descriptor="string">
    <!-- Zero or more repetitions: -->
    <bsvc:ID bsvc:type="string">string</bsvc:ID>
 </bsvc:Bill_To_Address_Reference>
 <!-- Zero or more repetitions: -->
 <bsvc:Address_Reference>
    <!-- Optional: -->
    <bsvc:ID>string</bsvc:ID>
 </bsvc:Address_Reference>
</bsvc:Bill_To_Address_Data>

下面是上面xml的xsd块

<xsd:complexType name="Bill_To_Address_ReferenceType">
    <xsd:annotation>
    <xsd:documentation>Contains a reference instance or a Address Reference ID for an existing address</xsd:documentation>
    <xsd:appinfo>
        <wd:Validation>
        <wd:Validation_Message>The Provided Bill To Address is Invalid for this Purchase Order</wd:Validation_Message>
        </wd:Validation>
        <wd:Validation>
        <wd:Validation_Message>The Provided Bill To Address is Invalid for this Purchase Order</wd:Validation_Message>
        </wd:Validation>
    </xsd:appinfo>
    </xsd:annotation>
    <xsd:sequence>
    <xsd:choice>
        <xsd:element name="Bill_To_Address_Reference" type="wd:Unique_IdentifierObjectType" minOccurs="0">
        <xsd:annotation>
            <xsd:documentation>Reference to an existing Ship-To address.</xsd:documentation>
        </xsd:annotation>
        </xsd:element>
        <xsd:element name="Address_Reference" type="wd:Address_ReferenceType" minOccurs="0" maxOccurs="unbounded">
        <xsd:annotation>
            <xsd:documentation>Address Reference ID</xsd:documentation>
        </xsd:annotation>
        </xsd:element>
    </xsd:choice>
    </xsd:sequence>
</xsd:complexType>

在针对 WSDL 中的 XSD 验证 XML 时,我在氧气中确认了这一点,或者可以在此处访问

现在我想要的是忽略这个错误并使用 zeep 解析 python 中的响应。任何帮助将不胜感激。

4

1 回答 1

1

您的选择是:

  1. 修改 WSDL(XML 模式部分),以便在同一个请求中允许两个标签
  2. 在 Zeep 中查找允许您关闭 XSD 验证的设置
  3. 停止使用 Zeep,并找到另一个工具,让您无需验证 WSDL 即可解析请求

选项 1 是最好的,因为 WSDL 应该是服务与其调用者之间的契约。如果您不进行验证,那么使用 WSDL 的价值就会大大降低。

于 2021-02-10T12:37:21.110 回答