GET запрос я смог сделать. Использовал HttpsURLConnection.
Код: Выделить всё
public void authorization(){
try
{
URL url = new URL("https://myURL.ru/monit/mobile/vehicle/login");
HttpsURLConnection con;
con= (HttpsURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("accept", "application/xml");
/////
SSLContext ctx = SSLContext.getInstance("TLS");
ctx.init(null, new TrustManager[] {
new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType) {}
public void checkServerTrusted(X509Certificate[] chain, String authType) {}
public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[]{}; }
}
}, null);
HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
/////
if (isCancelled()) return;
try
{
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
Log.i("POST-GET", response.toString());
// ParseV(response.toString());
}
catch (IOException e) { e.printStackTrace(); }
}
catch (Exception e)
{
Log.d("Error GetServer", "Message error " + e.toString());
Log.i("d", e.toString());
this.cancel(true);
}
}Как отправить на сервер POST запрос с параметрами(логин, пароль), используя SSL ? ....
Кто знает не проходите мимо пожалуйста!
