What i'm trying to do is transfer an image from the web service to the mobile client. In order to do this i've created a web service operation that returns a byte[] variable. In this method i create an .png image from a chart. After this i get the bytes from the image and provide them as a return value for the operation. this is the server code:
public byte[] getBytes() throws IOException {
BufferedImage chartImage = chart.createBufferedImage(230, 260); //I get the image from a chart component. ByteArrayOutputStream baos = new ByteArrayOutputStream(1000);
ImageIO.write( chartImage, "png",baos );
baos.flush(); byte[] bytesImage = baos.toByteArray();
baos.close();
return bytesImage; }
Now in the mobile application all i do is assign a byte[] variable the return value of the web service operation.
byte[] imageBytes = Stub.getBytes().
Maybe i'm missing something but this is not working as i get this runtime error:
java.rmi.MarshalException: Expected Byte, received: iVBORw0KGgoAAAANSUhEU.... (very long line).
have any ideas why this happends? Or maybe you can suggest any other way to send the data to the mobile client. Thanks