-2

FlushCacheonDP.xml:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
    <m:request xmlns:m="http://www.datapower.com/schemas/management" domain="XXXXX">
        <m:do-action>
            <FlushDocumentCache>
                <XMLManager class="XMLManager">default</XMLManager>
            </FlushDocumentCache>
            <FlushStylesheetCache>
                <XMLManager class="XMLManager">default</XMLManager>
            </FlushStylesheetCache>
        </m:do-action>
    </m:request>
</SOAP-ENV:Body>

I am using it in a curl call inside a python script, my problem is I want to call the curl with the above xml but the domain="XXXXX" has to pick differents strings like from an array.

here is how I am calling it :

from sys import argv
import subprocess
# run python cache2.py hosts.txt Test
with open(argv[1]) as f:
addresses = {i.split(" : ")[0] : i.split(" : ")[1] for i in f}
print(addresses[argv[2]])


command = "curl -k --data-binary @FlushCacheonDP.xml -u username@password   https://" +addresses[argv[2]].strip()+ ":5550/service/mgmt/current > Response2\generated_Resp.xml"
print(command)
p = subprocess.Popen(command,shell=True,  stdout=subprocess.PIPE).communicate()[0]

arrayDomain = ['EOT','ITD_TEST',......,'NSOPR']

I could call the same curl script many times, but it will be a redandont Thanks, your help is appreciated.

Bouchaib Mounir
  • 1,293
  • 2
  • 14
  • 16
  • What is your question? – Robᵩ Oct 22 '15 at 17:48
  • and what is the result of your code executing? What is the typical usage of the command line, with sample input? – Shawn Mehan Oct 22 '15 at 17:49
  • The input is that xml file, when sent to the datapower server, this one reply by another xml file, everything is working fine, my question is there any way to inject domain from the arrayDomail to the FlushCacheonDP.xml before it will be sent ? – Bouchaib Mounir Oct 22 '15 at 18:14
  • So you are trying to change the domain attribute of your request element? You may wish to check out http://stackoverflow.com/questions/1591579/how-to-update-modify-a-xml-file-in-python – user2085282 Oct 22 '15 at 18:17
  • I want to read the xml file, change only the XXXX write it back to system, then call curl : my_file = open(filename, "r") lines_of_file = my_file.readlines() how to do string manipulation here ??? my_file.writelines(lines_of_file) – Bouchaib Mounir Oct 22 '15 at 19:05

1 Answers1

0

I am all set I used minidom: .attributes["domain"].value = domain Thanks.

Bouchaib Mounir
  • 1,293
  • 2
  • 14
  • 16