Galera,
O Web Service que vou consumir utiliza Https, sendo assim o que devo alterar no meu código abaixo pra funcionar a requisição?
@Override
protected Void doInBackground(Void... params) {
try {
Gson gson = new Gson();
String urlCnx = urlWs+"athusr?CUSUARIO="+login+"&CSENHA="+senha;
StringBuilder execucao = new StringBuilder();
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
try {
URL url = new URL("https://webserviceteste/get/teste");
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setRequestProperty("Content-type", "application/json");
urlConnection.setRequestProperty("Accept", "application/json");
urlConnection.setDoOutput(true);
urlConnection.setConnectTimeout(Integer.valueOf(timeOut));
urlConnection.connect();
Scanner scanner = new Scanner(url.openStream());
while (scanner.hasNext()) {
execucao.append(scanner.next());
}
conexaows = gson.fromJson(execucao.toString(), Login.class);
urlConnection.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(conexaows.toString());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Alguma sugestão?
Obrigado