2012-10-11 53 views
2

我的web服務在.net中,我已經成功地從android響應中使用KSOAP2獲取數據。我想從頭文件中獲得Response Header和一些細節,任何人都可以幫助如何使用KSOAP2獲取Response頭文件?從android使用Ksoap2從web服務獲取Respose標題

+0

如何使用KSOAP2在android中連接服務器時probelem中respose的狀態代碼? – Roshni

回答

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()); 
} 
+0

希亞姆感謝您的答覆,但我得到調用Webservice的 1ef9fd6a-da32-48cc-af3e-45952f471d62真正<的ErrorMessage /><登錄的方法後,下面的Web瀏覽器/ CRMResponse> – Roshni

+0

調用方法中的第三個參數是什麼? – Roshni