Android 调用webservice保存和传递cookie
1、登入时保存cookie,如下: List headerList = transport.call(m_SoapActio荏鱿胫协n, envelope, null); String cookie = ""; //用于保存cookie的字符串 for (Object header : headerList) { HeaderProperty headerProperty = (HeaderProperty) header; String headerKey = headerProperty.getKey(); String headerValue = headerProperty.getValue(); Log.i("COOK", headerKey + "== " + headerValue); if (headerKey != null && headerKey.equals("Set-Cookie")) { cookie = headerKey + ":" + headerValue; Log.i("xx", "cookie == " + cookie); cookie = headerValue; } }
2、上传时获取cookie敛财醣沁并传递,如下: if (cookie != null) { HeaderProperty headerPropertyObj = new Header霸烹钟爷Property("cookie",cookie); headerList.clear(); headerList.add(headerPropertyObj); transport.call(m_HZSoapAction, envelope, headerList); }
3、主要是call函数的第三个参数,返回的也是List类型