Necesidad de transferir el archivo .apk mediante webservice

He convertido mi archivo apk en array de bytes y lo envío usando webservice como sigue

[WebMethod] public byte[] GetApkFile(string deviceID) { try { string path = ServiceHelper.GetTempFilePath(); string fileName = path + "\\VersionUpdate.apk"; FileStream fileStream = File.OpenRead(fileName); return ConvertStreamToByteBuffer(fileStream); } catch (Exception ex) { throw ex; } } public byte[] ConvertStreamToByteBuffer(System.IO.Stream theStream) { int b1; System.IO.MemoryStream tempStream = new System.IO.MemoryStream(); while ((b1 = theStream.ReadByte()) != -1) { tempStream.WriteByte(((byte)b1)); } return tempStream.ToArray(); } 

He consumido el servicio web utilizando el protocolo ksoap en mi aplicación android como bytes de matriz como se indica a continuación

 public void DownloadApkFile(String serverIPAddress, String deviceId) { String SOAP_ACTION = "http://VisionEPODWebService/GetApkFile"; String OPERATION_NAME = "GetApkFile"; String WSDL_TARGET_NAMESPACE = "http://VisionEPODWebService/"; String SOAP_ADDRESS = ""; SOAP_ADDRESS = "http://" + serverIPAddress + "/VisionEPODWebService/SystemData.asmx"; SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER10); new MarshalBase64().register(envelope); envelope.encodingStyle = SoapEnvelope.ENC; request.addProperty("deviceID", deviceId); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS); try { httpTransport.call(SOAP_ACTION, envelope); Object response = envelope.getResponse(); byte[] b=response.toString().getBytes(); String fileName = "/sdcard/" + "VersionUpdate" + ".apk"; FileOutputStream fileOuputStream = new FileOutputStream(fileName); fileOuputStream.write(b); fileOuputStream.close(); } catch (Exception exception) { exception.toString(); } 

El problema es que no estoy consiguiendo el archivo apk exacto después de convertir la matriz del byte [] de nuevo al archivo.

¿Alguien puede revisar el código y por favor dígame que hay algún error en esto.

Mi necesidad de obtener el archivo convertido byte [] apk de nuevo al archivo .apk en el sdcard para la instalación.

response.toString() es probable que no sea una representación de cadena de su APK.

Pruebe lo siguiente:

 SoapObject result = (SoapObject)envelope.bodyIn; byte[] b=result.toString().getBytes(); 
  • Bloquear usuarios no Android que llaman al servicio JSON
  • Cómo llamar a un servicio web SOAP en Android
  • Ksoap2 Android - ¿cómo especificar un espacio de nombres para las propiedades secundarias de un objeto complejo?
  • Transferir datos de ArrayList al servicio web SOAP en android
  • ¿Cómo llamar a un servicio web RESTful de Android?
  • Java REST cliente API para Android
  • ¿Qué authTokenType significa exactamente?
  • Cuál es el papel de la clave de la aplicación y la clave secreta en cada SDK
  • Envío de SQLite db al servicio web
  • ¿Pasar datos a los servicios web .net y obtener resultados?
  • Autenticación de Webservice de iPhone y token de acceso
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.