Skip to content

Instantly share code, notes, and snippets.

@rafaelhenrique
Created November 4, 2015 17:35
Show Gist options
  • Save rafaelhenrique/f810719c71d407c6609d to your computer and use it in GitHub Desktop.
Save rafaelhenrique/f810719c71d407c6609d to your computer and use it in GitHub Desktop.
Script to send generic post to generic api SOAP (xml)
# -*- 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