How to send a request using suds client with several elements in the request

I am having a problem sending a foaming request.

I sent the request to another method using only the following:

from suds.client import Client

   client = Client(wsdlurl)

   client.service.Login(name, employid)

This came back with the correct answer, as the name and usage are direct children of Login.

But how can I send a request using below:

 <soapenv:Body>
      <v12:getStuff>
         <v12:stuffSelect>
            <!--Optional:-->
            <v12:stuffIDs>
               <!--Zero or more repetitions:-->
               <v12:num></v12:num>
            </v12:stuffIDs>
         </v12:stuffSelect>
      </v12:getStuff>
   </soapenv:Body>
</soapenv:Envelope>

The reason for this is that I can add dynamic value to num

I tried like this:

return self.client.service.getStuff.stuffSelect.stuffIDs(**{'stuffID': stuff_id, })

But get this error

AttributeError: 'Method' object has no attribute 'stuffSelector'
+4
source share
1 answer

, https://bitbucket.org/jurko/suds. , wsdl; :

# ... 'client' via wsdl url, login

# get example
http_status, payload = client.service.your_wsdl_get_stuff_method()
stuffIDs = []
if http_status == 200:
    for stuff_id in payload:  # depending on your wsdl
        stuffIDs.append(stuff_id)

# upload example
stuffSelect = client.factory.create('stuffSelect')  # structure generated by suds from wsdl
stuffSelect.your_wdsl_stuff_ids_name = stuffIDs  # (maybe debug to see your name)

params = foo, bar, stuffSelect
svr_response = client.service.your_wsdl_upload_method(*params)
0

Source: https://habr.com/ru/post/1673816/


All Articles