How to iterate throught parameters of a soap protocol

Question:

I try to make a loop on a function that contains the get method on soap protocol to have the list of ActionList that have appointments at the workshop.

here is the code I managed to do :

def get_xml():
    for iddms in ['7','16','15','10','25','8','11','12','14','13']:
        for idaction in ['1','2']:
            url = "http://url.com/soap/IWSDialog"
            headers = {"content-type" : "application/soap+xml ; charset=utf-8 "}
            body ="""<soapenv:Envelope>
               <soapenv:Header/>
                   <soapenv:Body>
                          <urn:getActionList>
                             <EntId >1013</EntId>
                             <DMSId>"""+iddms+"""</DMSId>
                             <GroupActionId>"""+idaction+"""</GroupActionId>
                          </urn:getActionList>
                   </soapenv:Body>
                </soapenv:Envelope>"""
        ActionList = requests.post(url,data=body,headers=headers)
    return ActionList.content
ActionList = get_xml()

I am blocked how to iterate two parameters :DMSId,GroupActionId and append the result.

Any help will be highly appreciated.

Thank you in advance

Asked By: wysouf

||

Answers:

The answer to my question was to make a loop then create a dataframe from the content for each iteration like this:

url = "http://url.com/soap/IWSDialog"
headers = {"content-type" : "application/soap+xml ; charset=utf-8 "}
tree = pd.DataFrame()

for iddms in ['7','16','15','10','25','8','11','12','14','13'] :
   for idaction in ['1','2']:
            url = "http://url.com/soap/IWSDialog"
            headers = {"content-type" : "application/soap+xml ; charset=utf-8 "}
            body ="""<soapenv:Envelope>
               <soapenv:Header/>
                   <soapenv:Body>
                          <urn:getActionList>
                             <EntId >1013</EntId>
                             <DMSId>"""+iddms+"""</DMSId>
                             <GroupActionId>"""+idaction+"""</GroupActionId>
                          </urn:getActionList>
                   </soapenv:Body>
                </soapenv:Envelope>"""
        
        
            ActionList = requests.post(url, data=body, headers=headers)
            result = ActionList.content
            ActionList = pd.read_xml(result , xpath= "//NS2:path", namespaces={"NS2":"urn:WSD"})
            df= pd.concat([ActionList, df])
Answered By: wysouf
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.