我正在尝试在 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_Reference
和Address_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 中的响应。任何帮助将不胜感激。