I am porting my code to android 6.0. Since apache classes have already been deprecated and removed in API 23, I cant find a exact match for my previous code to make a HTTPS connection. Following is my code
try {
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(new Scheme("https",new CustomSSLSocketFactory(), 443));// new CustomSSLSocketFactory().newSslSocketFactory(context.getResources()), 443));
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 120000);
ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(httpParameters, schemeRegistry);
httpClient = new DefaultHttpClient(cm, httpParameters);
setHttpClient(httpClient);
AbstractMediator.setServerTime(System.currentTimeMillis());
httpResponse = httpClient.execute(request);
serviceResponseObject.setResponseCode(httpResponse.getStatusLine().getStatusCode());
serviceResponseObject.setMessage(httpResponse.getStatusLine().getReasonPhrase());
serviceResponseObject.setAllHeader(httpResponse.getAllHeaders());
Header[] header = httpResponse.getAllHeaders();
}catch (UnknownHostException e){
Utility.printStackTrace(e);
serviceResponseObject.setResponseBody("");
return responseWithErrorCode(NETWORK_ERROR_CODE101, serviceResponseObject);
} catch (IOException e) {
Utility.printStackTrace(e);
return responseWithErrorCode(NETWORK_ERROR_CODE100, serviceResponseObject);
} catch (Exception e) {
Utility.printStackTrace(e);
return responseWithErrorCode(NETWORK_ERROR_CODE100, serviceResponseObject);
}
I have read this link Deprecated: org.apache.http.conn.scheme.scheme is deprecated. It do mention about scheme class new constructor, but not about rest of the methods. My app min API level is 14 and would be glad if any substitute method do respect it.
I have read this 'org.apache.http.HttpEntity' is deprecated. How to solve this error in android studio? which talks about using apache legacy and the other solution regarding Marek Sebera's new Apache HttpClient package for Android, but that does not serve my purpose.
I cant use libraries like Volley, Retrofit, OKHttp as i have web services in Soap XML format
I want to migrate away from apache completely. My concern is to know what all methods in HttpsUrlConnection class can be used for replacement. I would appreciate if i get a code regarding this which do exactly what i am doing above but with new API methods. I came to know about classes like Registry, PoolingHttpClientConnectionManager but i cant understand how to use them to attain above results