1

I'm trying to consume a SOAP service using Zeep and I'm having a hard time trying to implement this call.

So I got the following request for a given operation in a given SOAP

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body xmlns:ns1="http://xxxxxxxxxxxxxxx/">
        <ns1:Something>
            <ns1:List_1>
                <ns1:item>
                    <ns1:key>VALUE_1</ns1:key>
                    <ns1:value>some_value</ns1:value>
                </ns1:item>
                <ns1:item>
                    <ns1:key>VALUE_2</ns1:key>
                    <ns1:value>some_value</ns1:value>
                </ns1:item>
                <ns1:item>
                    <ns1:key>VALUE_3</ns1:key>
                    <ns1:value>some_value</ns1:value>
                </ns1:item>
                </ns1:item>
                <ns1:item>
                    <ns1:key>VALUE_4</ns1:key>
                    <ns1:value>some_value</ns1:value>
                </ns1:item>
                <ns1:item>
                    <ns1:key>VALUE_5</ns1:key>
                    <ns1:value>some_value</ns1:value>
                <ns1:item>
                    <ns1:key>VALUE_6</ns1:key>
                    <ns1:value>some_value</ns1:value>
                </ns1:item>
            </ns1:List_1>
        </ns1:Something>
    </soap:Body>
</soap:Envelope>
 

My understanding of this, in the request is a field called List_1 with a list of fields called Item, which every one of them have a key param and a value param.

So I'm trying the following

client = Client('http://some.url.com/service?WSDL')

with client.settings(strict=False):
    val1 = {'item': {'key': 'VALUE_1', 'value': 'asdsadsad'}}
    val2 = {'item': {'key': 'VALUE_2', 'value': 'asdasdasdas'}}
    val3 = {'item': {'key': 'VALUE_3', 'value': 'asdasdadcxdsa'}}
    val4 = {'item': {'key': 'VALUE_4', 'value': 'asdasdsdasdasd'}}
    val5 = {'item': {'key': 'VALUE_5', 'value': 'test'}}
    val6 = {'item': {'key': 'VALUE_6', 'value': 'asdasdasdadsa'}}

    list_request =  [val1, val2, val3, val4, val5, val6]
    response  = client.service.something(List_1 = list_request)
    print(response)

The thing is, some values are required, lets say VALUE_1 and VALUE_5 are requiered, and when I try that implementation, I get a response from the SOAP saying VALUE_5 can't be empty, which is weird because I'm sending it, but at least I know I'm being able to call the service, so I did some tests and seems like even if I'm sending a list of values, zeep is only reading the last value of the list, for exmaple:

if I send this list:

list_request =  [val1, val5 ]

I get an error from the service telling me VALUE_1 can't be empty, but if I send this list

list_request =  [val5, val1 ]

I get an error from the service telling me VALUE_5 can't be empty.

So I think I'm doing something wrong in the way I'm constructing the request object, but I can't see what is wrong with it.

Zero23ku
  • 11
  • 4
  • Related question with an answer - https://stackoverflow.com/questions/49847976/python-axl-soap-w-zeep-how-to-avoid-duplicate-dictionary-keys – Sajjad Nazrulla Mar 15 '23 at 10:44

0 Answers0