顺序选择-使用Zeep

时间:2019-12-21 19:10:26

标签: python xml soap zeep

使用zeep库时遇到以下问题。我的XSD具有以下XML结构:

<xs:complexType name="cofPaymentType">
    <xs:sequence>
        <xs:choice>
            <xs:sequence>
                <xs:element name="paymentInstrument" type="tns:paymentInstrument"/>
                <xs:element name="payment" type="tns:paymentType"/>
                <xs:element name="cvvCode" type="tns:cvvCodeType" minOccurs="0"/>
            </xs:sequence>
            <xs:sequence>
                <xs:element name="encryptedData" type="tns:encryptedDataType"/>
                <xs:element name="payment" type="tns:paymentType"/>
            </xs:sequence>
        </xs:choice>
        <xs:element name="tdsAuthResult" type="tns:tdsAuthResult" minOccurs="0"/>
    </xs:sequence>
</xs:complexType>

我正在传递以下数据:

data = {"encryptedData": {"field1": "foo", "field2":  "bar"}, "payment": payment}
response = client.service.payment(**data)

我收到的答复:

{http://www.example.pl/integration/virtual/transaction/v1}cofPaymentType() got an unexpected keyword argument 'encryptedData'. Signature: `({paymentInstrument: {http://www.example.pl/integration/virtual/transaction/v1}paymentInstrument, payment: {http://www.example.pl/integration/virtual/transaction/v1}paymentType, cvvCode: {http://www.example.pl/integration/virtual/transaction/v1}cvvCodeType} | {encryptedData: {http://www.example.pl/integration/virtual/transaction/v1}encryptedDataType, payment: {http://www.example.pl/integration/virtual/transaction/v1}paymentType}), tdsAuthResult: {http://www.example.pl/integration/virtual/transaction/v1}tdsAuthResult`"}

但是第二个选择中出现字段cryptocurredData。看起来只有首选。我对吗?如何获得第二选择?

我也尝试使用factory = client.type_factory('ns0')创建请求,但结果相同。它没有看到第二选择的元素。

通常,zeep在将请求转换为XML结构时遇到问题。因此,我什至无法生成:https://python-zeep.readthedocs.io/en/master/client.html#creating-the-raw-xml-documents,因为上述“获得了意外关键字”。

0 个答案:

没有答案