1

我有大小约为 5 mb 的 db 文件,我已转换为字节数组列表,并希望将其传递给我的 Web 服务以保存在服务器上,但我得到无法序列化错误。我在下面附上我的代码......

            SoapObject soap_request = new SoapObject(NAMESPACE, METHOD_NAME1);
            fileName = "DB"+UserID+"_"+backupDateTime+".db";

            PropertyInfo pi1 = new PropertyInfo();
            pi1.setName("_FileName");
            pi1.setType(String.class);
            pi1.setValue(fileName);
            soap_request.addProperty(pi1);

            PropertyInfo pi2 = new PropertyInfo();
            pi2.setName("_ByteArray");
            pi2.setType(ArrayList.class);
            pi2.setValue(data);
            soap_request.addProperty(pi2);

            PropertyInfo pi3 = new PropertyInfo();
            pi3.setName("UserID");
            pi3.setType(Integer.class);
            pi3.setValue(UserID);
            soap_request.addProperty(pi3);

            Log.v(TAG, "soap_request _FileName= >>"+soap_request.getProperty(0));
            Log.v(TAG, "soap_request _ByteArray= >>"+soap_request.getProperty(1));
            Log.v(TAG, "soap_request UserID= >>"+soap_request.getProperty(2));

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            //new MarshalBase64().register(envelope);
            envelope.setOutputSoapObject(soap_request);
            envelope.dotNet = true;

            Log.v(TAG,"Calling webservice....");
            androidHttpTransportSE = new HttpTransportSE(URL);
            androidHttpTransportSE.debug = true;
            androidHttpTransportSE.call(SOAP_ACTION1, envelope);

            Log.v(TAG,"Getting result from webservice....");
            SoapObject result = (SoapObject) envelope.bodyIn;
            JSONObject response = new JSONObject(result.getProperty(0).toString());
            Log.v(TAG, "Web Response...." + response.get(" Result "));

            if (response.get(" Result ").equals("Uploading DataBase Backup To Server successfully"))
            {
                flag = true;
                Log.v(TAG, "Database is uploaded .........");
            }
4

1 回答 1

0

尝试改变这个

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
//new MarshalBase64().register(envelope);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
new MarshalBase64().register(envelope); // this line is for serialization

我猜你也会从这个链接中更好地了解你的问题。

希望它会帮助你。

于 2013-02-12T07:36:28.920 回答