Query is the xml string that you want to send. Modify the content type according to your needs.
def send_xml_query(self, query, host, port):
query = query.replace ('\n', '')
headers = {"Content-type": "application/xml"}
host = 'http://%s:%s' % (host, port)
request = urllib2.Request(host, query, headers)
response = urllib2.urlopen(request)
return request, response