Python post to soap service undefined behaviour -


i have following in python 2.6, works perfectly.

webservice = httplib.http("www.racai.ro:80") webservice.putrequest("post", "/webservices/textprocessing.asmx?wsdl")   webservice.putheader("host", "www.racai.ro") webservice.putheader("user-agent", "python") webservice.putheader("content-type", "text/xml; charset=\"utf-8\"") webservice.putheader("content-length", "%d" % len(f)) webservice.endheaders() webservice.send(f) 

now, have following in python 3.1 on bad request(invalid header name).

tstring = template.format(text)    webservice = http.client.httpconnection("www.racai.ro:80") webservice.putrequest("post", "/webservices/textprocessing.asmx?wsdl") webservice.putheader("host", "www.racai.ro") webservice.putheader("user-agent", "python") webservice.putheader("content-type", "text/xml; charset=\"utf-8\"") webservice.putheader("content-length", "%d" % len(tstring)) webservice.endheaders() tstring = tstring.encode() webservice.send(tstring) 

what doing wrong?

this solution(on python 3.3):

def send_soap_request(soap_message):    webservice = httpconnection('www.example.host:80')    request_headers = {"host": 'www.example.host:80',                    "content-type": 'text/xml;charset="utf-8"',                    "soapaction": '""', }    webservice.request("post", '/messager/example_service/sendmessage', soap_message.encode('utf8'), request_headers)    webservice.getresponse()    webservice.close() 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -