#!/usr/bin/env python import httplib import sys SM_TEMPLATE = open(sys.argv[1], 'r') SoapMessage = SM_TEMPLATE.read() CERTFILE = "MyCertificate.cer" KEYFILE = "MyPrivateKey.key" #print KEYFILE #print CERTFILE #The variable below is your host name followed by a colon and then the port your service is on. HOSTNAME = "localhost:2159" #USE THIS FOR HTTPS WITH CLIENT CERTIFICATES #conn = httplib.HTTPSConnection( HOSTNAME, key_file = KEYFILE, cert_file = CERTFILE ) #USE THIS FOR HTTPS WITHOUT CLIENT CERTIFICATES #conn = httplib.HTTPSConnection( HOSTNAME) #USE THIS FOR SIMPLE HTTP TESTING conn = httplib.HTTPConnection(HOSTNAME) #print SoapMessage #construct and send the header conn.putrequest('POST', '/WebSite1/Service.asmx') conn.putheader("Host", "myhostname.com") conn.putheader("User-Agent", "Python Script") conn.putheader("Content-type", "text/xml; charset=\"UTF-8\"") conn.putheader("Content-length", "%d" % len(SoapMessage)) #Sometimes you will have to comment out the soap action below... #conn.putheader("SOAPAction", "http://wijis.wisconsin.gov/specs/schemas/record/v1.1/2007-01-12/retrieveRecords") conn.endheaders() conn.send(SoapMessage) response = conn.getresponse() print response.read()