Galera o metodo getByteArray de meu webservice está retornando um vetor de bytes, estou tentando pega-lo no cliente sem sucesso, não sei como converter o objeto retornado para um vetor de byte, lembrando que estou usando a ferramenta ksoap, alguem poderia me dar uma ajuda?
segue abaixo os codigos.
Servidor:
/**
* Operação de serviço web
*/
@WebMethod(operationName = "getByteArray")
public byte[] getByteArray() throws Exception {
//TODO grava o seu código de implementação aqui:
FileInputStream file = new FileInputStream("D:/11-10-09_1558.jpg");
byte[] aux = new byte[1024];
byte[] total = null;
byte[] buffer;
int cont;
while ((cont = file.read(aux)) > 0) {
if (total != null) {
buffer = new byte[total.length + cont];
for (int pos = 0; pos < total.length; pos++) {
buffer[pos] = total[pos];
}
for (int pos = 0; pos < cont; pos++) {
buffer[pos+total.length] = aux[pos];
}
total=buffer;
} else {
total = aux;
}
aux = new byte[1024];
}
file.close();
System.out.println("Saida: "+ total.length);
return total;
}
Cliente:
SoapObject client = new SoapObject("http://Serv/", "getByteArray");
// client.addProperty("DATA", "");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(client);
HttpTransportSE conecta = new HttpTransportSE("http://localhost:8084/MobileServ/Sample");
try {
conecta.call("", envelope);
envelope.getResponse();
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (XmlPullParserException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}