android - Unable to send data to server in Json format using Soap Api getting base64 image can not be serlize -


class download1 extends asynctask<void, void, void> {      @override     protected void onpreexecute() {             super.onpreexecute();     }      @override     protected void doinbackground(void... params) {         // todo auto-generated method stub          try {             soapobject objsavevisitinfradetails = new soapobject(namespace,                     postmethod_name);             jsonarray jsonarr = new jsonarray();             jsonobject pnobj = new jsonobject();             treemap<integer, string> map=new treemap<integer, string>();             bitmap bmp = bitmapfactory.decoderesource(getresources(),                     r.drawable.ic_launcher);             bytearrayoutputstream stream = new bytearrayoutputstream();             bmp.compress(bitmap.compressformat.png, 100, stream);             byte[] bytearray = stream.tobytearray();              (int = 0; < 2; i++) {                 pnobj.put("feedback",                         "this feedback");                 pnobj.put("infravisit", integer.parseint("1"));                 map.put(i+1,org.kobjects.base64.base64.encode(bytearray));                 pnobj.put("infraid", integer.parseint("1"));                 pnobj.put("resolvestatus", boolean.valueof("true"));                 pnobj.put("visitdetailid",  integer.parseint("1"));                 pnobj.put("visit_masterid",  integer.parseint("1"));                 jsonarr.put(pnobj);              }              objsavevisitinfradetails.addproperty("jsonstring",                     jsonarr.tostring());             objsavevisitinfradetails.addproperty("visitmasterid", 1);             objsavevisitinfradetails.addproperty("dicimage", map);              envelope = new soapserializationenvelope(soapenvelope.ver11);             envelope.dotnet = true;             envelope.setoutputsoapobject(objsavevisitinfradetails);              httptransportse androidhttptransport = new httptransportse(url);             androidhttptransport.debug = true;             marshal datemarshal = new marshalbase64();             datemarshal.register(envelope);             androidhttptransport.call(postsoap_action, envelope);                log.d("responseeeeeeeeeeeeeeeeeeeeeeeee",                     androidhttptransport.requestdump);             log.d("responseeeeeeeeeeeeeeeeeeeeeeeee222",                     androidhttptransport.responsedump);             soapobject result = (soapobject) envelope.getresponse();             string name = result.getproperty(0).tostring();         } catch (soapfault e) {             // todo auto-generated catch block             e.printstacktrace();         } catch (ioexception e) {             // todo auto-generated catch block             e.printstacktrace();         } catch (xmlpullparserexception e) {             // todo auto-generated catch block             e.printstacktrace();         }          catch (nullpointerexception e) {             // todo: handle exception             log.d("errorrr", e.getmessage());              system.out.println(e.getmessage());         } catch (jsonexception e) {             // todo auto-generated catch block             e.printstacktrace();         }         return null;     }      @override     protected void onpostexecute(void result) {         // todo auto-generated method stub         super.onpostexecute(result);         toast.maketext(mainactivity.this, "sucess!  ", 10000).show();      }  } 

hi asynktask send multiple data server using 1 @ time have convert string data json format , image in hashmap base64 string format in key value pair unable send getting error base64 string can not serialized please tell me how send image can serlized image , send data server

i have done thing using code :

final byte temp[] = read(fileselected);             // send media             connectiondetector cd = new connectiondetector(getapplicationcontext());             boolean isinternetpresent = cd.isconnectingtointernet();             if(isinternetpresent)             {                 pb.setvisibility(view.visible);                 ibtnsendchatnote.setenabled(false);                 final string soap_action = "http://xxxxx/xxxxxx/insertmedia";                 final string method_name = "insertmedia";                 final string namespace = "http://xxxxx/";                 thread networkthread = new thread() {                 @override                 public void run() {                   try {                         soapobject request = new soapobject(namespace, method_name);                         soapserializationenvelope envelope = new soapserializationenvelope(soapenvelope.ver11);                         envelope.setoutputsoapobject(request);                         new marshalbase64().register(envelope);                         httptransportse ht = new httptransportse(ipconfig.url);                         request.addproperty("sid", sid);                         request.addproperty("notecontent", filepath[filepath.length-1]);                         request.addproperty("notetype", "mobile");                         request.addproperty("mediacontent", temp);                                                   ht.call(soap_action, envelope);                         final soapprimitive sp = (soapprimitive) envelope.getresponse();                          runonuithread (new runnable(){                             public void run() {                                 pb.setvisibility(view.gone);                                                 ibtnsendchatnote.setenabled(true);                                 if(sp.tostring().equals("true"))                                 {                                     // ever want                                 }                                 else                                 {                                     toast.maketext(getapplicationcontext(), "error while sending", toast.length_short).show();                                 }                                 ibtnsendchatnote.setenabled(true);                              }                          });                   }                   catch (exception e) {                       e.printstacktrace();                   }                 }                 };                 networkthread.start();             }             else             {                 toast.maketext(getapplicationcontext(), "please connect internet!", toast.length_short).show();             } 

get byte[] using filepath

public static byte[] read(string filepath) {         try {             file file = new file(filepath);             fileinputstream fis = new fileinputstream(file);             byte[] b = new byte[(int) file.length()];             fis.read(b);             fis.close();             return b;         } catch (exception ex) {             return null;         }     } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -