Search code examples
androidhttp-headersksoap2

Add header to Http Header


I am using ksoap2 for android project. But server code (which cannot be changed) is old and needs send some properties inside a header on HTTP header.

Server use soap so I decided to use ksoap2 for android but I couldn't find any example how to set http header of ksoap2 request(not inside soap envelope but inside of httpheader).

Is it possible?

If possible can anyone show me a example?


Solution

  • You can retrieve the connection object and add the headers there.

    HttpTransportSE transport = new HttpTransportSE(url,timeout);
    ServiceConnection conn = transport.getConnection();
    conn.setRequestProperty("Accept-Encoding", "utf-8");
    //and others...