我正在使用ksoap2进行Web服务方法调用.我使用ksoap2-android-assembly-2.5.4-jar-with-dependencies.jar并能够从Web服务响应中检索标头值.我想保存任何返回的cookie,并随后调用Web服务返回它们.
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
Run Code Online (Sandbox Code Playgroud)envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); List headerList = androidHttpTransport.call(SOAP_ACTION, envelope, null); for (Object header : headerList) { HeaderProperty headerProperty = (HeaderProperty) header; String headerKey = headerProperty.getKey(); String headerValue = headerProperty.getValue(); }
我试图将它保存在SharedPreferences中,但没有成功.我这么冷啊?请帮忙.
提前致谢.
问题解决了.
要保存标题内容:
Run Code Online (Sandbox Code Playgroud)Editor sharedPreferenceEditor = preferences.edit(); List headerList = androidHttpTransport.call(SOAP_ACTION, envelope, null); for (Object header : headerList) { HeaderProperty headerProperty = (HeaderProperty) header; String headerKey = headerProperty.getKey(); String headerValue = headerProperty.getValue(); System.out.println(headerKey +" : " + headerValue); sharedPreferenceEditor.putString(headerKey, headerValue); } sharedPreferenceEditor.commit();
根据要求设置cookie:
HeaderProperty headerPropertyObj = new HeaderProperty("cookie",preferences.getString("set-cookie",""));
headerList.add(headerPropertyObj);
androidHttpTransport.call(SOAP_ACTION,envelope,headerList);
| 归档时间: |
|
| 查看次数: |
4317 次 |
| 最近记录: |