3

My webservice is in .net and I have successfully get data from Soap Response using KSOAP2 in android. I want to get Response Header and some details from the header , Can any one help how to to get Response header using KSOAP2?

Shyam
  • 6,376
  • 1
  • 24
  • 38
Roshni
  • 31
  • 3
  • How to get status code in the respose if probelem with conneting to server in android using KSOAP2? – Roshni Oct 11 '12 at 09:24

1 Answers1

1
>   The HttpTransportSE class exposes the method call that, beyond the
> required SOAP    parameters, also accepts a List of HeaderProperty
> instances. It also returns a like List. This provides the ability to
> append additional headers to the request and review the returned
> headers. Since a cookie is just one of those header, one can use this
> facility to send and receive cookies.

The response headers are returned by the "call" method. So you just need to keep track of your JSESSIONID and pass it back again for each call. I overlooked this small detail at first as well. ;)

Keep in mind that the server returns the JSESSIONID with a "set-cookie" header, but it needs to be sent with a "cookie" header.

List respHeaders = android_http.call(SOAP_ACTION, envelope2, reqHeaders); 
for(int ix=0; ix<respHeaders.size(); ix++) { 
        HeaderProperty hp = (HeaderProperty)respHeaders.get(ix); 
        System.out.println("Header"+ix+"="+hp.getKey()+" / "+hp.getValue()); 
} 
Shyam
  • 6,376
  • 1
  • 24
  • 38
  • Shyam thanks for the reply but I am getting following on web browser after calling login method of Webservice 1ef9fd6a-da32-48cc-af3e-45952f471d62true – Roshni Oct 11 '12 at 06:21
  • And what is the 3rd parameter in the call method?? – Roshni Oct 11 '12 at 06:26