Created
November 4, 2015 17:35
-
-
Save rafaelhenrique/f810719c71d407c6609d to your computer and use it in GitHub Desktop.
Script to send generic post to generic api SOAP (xml)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import requests | |
headers = { | |
'Content-Type': 'text/xml; charset=utf-8', | |
'SOAPAction': ('http://127.0.0.1/GenericAction'), | |
} | |
url = 'http://127.0.0.1/GenericAction.svc' | |
# Read xml file | |
with open('payload_teste.xml') as fp: | |
payload = fp.read() | |
# Format xml file to send | |
payload = payload.replace("\n", "").encode('utf-8') | |
response = requests.post( | |
url, data=payload, headers=headers, verify=False) | |
# Format output | |
import xml.dom.minidom | |
xml = xml.dom.minidom.parseString(response.content).toprettyxml() | |
print(xml) | |
print(response.status_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment