Buenas
Estoy haciendo una .app la cual necesita consultar a un WS que contiene HTTPs.
El problema es que al tratar de hacerlo me genera un java.io.FileNotFoundException.
Adjunto les dejo el código:
Código:
public void call(String methodName, Object... args) throws IOException, IllegalArgumentException, IllegalAccessException, KeyStoreException, NoSuchAlgorithmException, CertificateException, KeyManagementException, UnrecoverableKeyException{
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
HttpsURLConnection conn = (HttpsURLConnection)mUrl.openConnection();
conn.setSSLSocketFactory(sslsocketfactory);
mMethodName = methodName;
//URLConnection conn = mUrl.openConnection();
conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
conn.addRequestProperty("SOAPAction", "http://tempuri.org/" + methodName);
conn.setConnectTimeout(5000);
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
String body = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>" +
"<" + methodName + " xmlns=\"http://tempuri.org/\">";
body += buildArgs(args);
body += "</" + methodName + ">"
+ "</soap:Body>"
+ "</soap:Envelope>";
wr.write(body);
wr.flush();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
mResult = "";
String line;
while ((line = rd.readLine()) != null) {
mResult += line;
}
wr.close();
rd.close();
}
Como se puede observar en el código yo estoy armando el .xml el cual envío al WS para poder obtener un response.
Esto lo hice desde un http y me funcionó utilizando el
Código:
URLConnection conn = mUrl.openConnection();
Alguno tiene alguna sugerencia del porque ocurre este error.
El URL existe, ya lo abrí desde el browser y no me da ningún problema.
En dado caso de que no les quede claro el WS les adjunto el link para que lo vean de ahí de manera mas clara y en caso de que les sea útil para el manejo entre WebServices. [URL="http://www.codeproject.com/Tips/222578/Android-access-to-NET-Web-Service-with-object-as-p"]WS[/URL]
Saludos