开发者

set encoding utf-8 for ksoap2 in android

开发者 https://www.devze.com 2023-04-03 16:55 出处:网络
I have problem with ksoap2, i want set encoding utf-8 for ksoap2 in android, or set content-type in header is text/xml,charset=utf=8,

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

envelope.encodingStyle = "utf-8";

//set header

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 not work. please help me. thanks.


I believe that it is done like so:

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

精彩评论

暂无评论...
验证码 换一张
取 消