Android无法序列化从压缩BMP收到的byte []

时间:2011-02-14 14:35:57

标签: android web-services serialization bitmap android-ksoap2

代码

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...
}

问题
当我将压缩的图像传递给我的webservice时,我得到一个运行时异常,说“无法序列化[B @ 47bcb6c8 ...”对我来说有些事情不明显,有人能看出为什么上面的(伪)代码不起作用吗?如果它有帮助,在Web服务服务器端,当服务器将传递的字节写入文件时(使用.Net IO.File.WriteAllBytes),似乎发生异常

堆栈跟踪
enter image description here

2 个答案:

答案 0 :(得分:2)

我需要这样做:

MarshalBase64 marshal;
marshal.register(envelope);

答案 1 :(得分:0)

SoapSerializationEnvelope信封=新的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();
相关问题