I have an android client that makes a request to a soap service. The soap service reads an image into a series of bytes and returns a byte array (quite a large one). Would this be seen as a primitive transfer type? The reason I ask is because I have the service code that reads an image and prints the first 5 bytes. Then it returns the byte array.
@Override
public byte[] getImage() {
byte[] imageBytes = null;
try {
File imageFile = new File("C:\\images\\car.jpg");
BufferedImage img = ImageIO.read(imageFile);
ByteArrayOutputStream baos = new ByteArrayOutputStream(1000);
ImageIO.write(img, "jpg", baos);
baos.flush();
imageBytes = baos.toByteArray();
baos.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
System.out.println("Got request");
System.out.println("****** FIRST 5 BYTES: ");
for(int i=0; i<5; i++) {
System.out.println("****** " + imageBytes[i]);
}
return imageBytes;
}
The output from the service on the server is
****** FIRST 5 BYTES:
****** -119
****** 80
****** 78
****** 71
****** 13
When I receive this on my android emulator, I print the first 5 bytes and they are completely different to those printed on the server. Here is my android code:
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
String result = resultsRequestSOAP.toString();
System.out.println("****** RESULT: " + result);
byte[] b = result.getBytes();
System.out.println("****** FIRST 5 BYTES: ");
for(int i=0; i<5; i++) {
System.out.println("****** " + b[i]);
}
And the output is
****** FIRST 5 BYTES:
****** 105
****** 86
****** 66
****** 79
****** 82
It works fine if I test it with a simple service client written in java. Any ideas why this might be happening?