Set utf-8 encoding for ksoap2 in android

I have a problem with ksoap2, I want to set utf-8 encoding for ksoap2 in android or set the content type in the header - text / xml, charset = utf = 8, my code: // set the encoding

envelope.encodingStyle = "utf-8"; 

// set the title

 envelope.headerOut = new Element[1]; envelope.headerOut[0] = buildAuthHeader(); private Element buildAuthHeader() { String namesc = "http://xml.apache.org/xml-soap"; Log.i("---build--","--buildAuthHeader--->"); Element h = new Element().createElement(namesc, "Headers"); Element username = new Element().createElement(namesc, "Content-Type"); username.addChild(Node.TEXT, "text/xml;charset=UTF-8"); h.addChild(Node.ELEMENT, username); return h; } 

but does not work. please, help. thanks.

+4
source share
1 answer

I believe this is done like this:

 HttpTransportSE transport = new HttpTransportSE(URL, TIME_OUT); transport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); 
0
source

All Articles