android JSON中的SessionExpiredException错误
在android RESTFUL Web服务中android JSON中的SessionExpiredException错误,android,json,session,ssl,json-rpc,Android,Json,Session,Ssl,Json Rpc,在android RESTFUL Web服务中 在HttpClient client=newdefaulthttpclient()中-我得到了成功的响应。 但是现在我的URL变成了http到https(SSL)并且此url不是受信任的证书。 所以我使用下面的@Daniel代码 如果我使用client=WebClientDevWrapper.getNewHttpClient()而不是DefaultClient()-我收到sessionExpiredException错误。 有什么帮助吗???我希
HttpClient client=newdefaulthttpclient()中代码>-我得到了成功的响应。
client=WebClientDevWrapper.getNewHttpClient()
而不是DefaultClient()
-我收到sessionExpiredException错误。有什么帮助吗???我希望你正在使用这种方法
public void connect() throws Exception {
HttpPost post = new HttpPost(new URI(""));
post.setEntity(new StringEntity(""));
trustAll();
HttpClient client = new DefaultHttpClient();
HttpResponse result = client.execute(post);
}
在HttpsURLConnection之前添加此代码,即可完成此操作
private void trustAll() {
try {
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier(){
public boolean verify(String hostname, SSLSession session) {
return true;
}});
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, new X509TrustManager[]{new X509TrustManager(){
public void checkClientTrusted(X509Certificate[] chain,
String authType) throws CertificateException {}
public void checkServerTrusted(X509Certificate[] chain,
String authType) throws CertificateException {}
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}}}, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(
context.getSocketFactory());
} catch (Exception e) {
Log.e("TAG",e);
}
}
此方法适用于我接受证书并尝试增加会话超时。首先尝试此方法,然后尝试传递主机名和布尔值。您的代码适用于登录页面url。但我在主页url中得到的会话已过期。我使用相同的会话id。