import sys, http.client
import urllib.request
host = "localhost:9000"
SM_TEMPLATE = """<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<ns1:helloWorld xmlns:ns1="http://webservice.kylinux.com/">
<arg0>%s</arg0>
<arg0>%s</arg0>
</ns1:helloWorld>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
"""
SoapMessage = SM_TEMPLATE%("Kylin", "Shu")
#print(SoapMessage)
#construct and send the header
webservice = http.client.HTTPConnection(host)
headers = {"Content-type": "text/xml; charset=\"UTF-8\""}
webservice.request("POST", "/WS/HelloWorld/", body=SoapMessage, headers=headers)
#headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
response = webservice.getresponse()
#print(response.status, response.reason)
data = response.read()
print(data)
webservice.close()