Android cannot serialize byte[] recieved from compressed BMP
The code
Bitmap bmp = (Bitmap)extras.get("data");
ByteArrayOutputStream out = new ByteArrayOutputStream();
bmp.compress(CompressFormat.JPEG, 100, out);
byte[] raw = out.toByteArray();
PassToWebservice(raw); //error
PassToWebservice(byte[] ba)
{
SoapObject envelope...
envelope.addProperty("base64bytes", ba);
...
transport.call(ACTION, envelope);
envelope.getResponse() //error: IOException cannot serialize...
}
The problem
When I pass the compressed image to my webservice, I get a runtimeexception that says "cannot serialize [B@47bcb6c8..." Something is not apparent to me, can anyone see why the above (psuedo) code does not work? If it helps, on the webservice server side, the exception seems to be happening when the server writes the passed bytes to a file (using开发者_StackOverflow .Net IO.File.WriteAllBytes)Stack trace
I needed to do this:
MarshalBase64 marshal;
marshal.register(envelope);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
new MarshalBase64().register(envelope); // this is will over Cannot serialize: [B@f034108
envelope.dotNet = true;
//Set output SOAP object
envelope.setOutputSoapObject(request);
//Create HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAPACTION, envelope);
SoapObject response = (SoapObject) envelope.getResponse();
精彩评论