How to send the base 64 encoded string from android to wcf -
i wrote functionality encode image , send wcf. um not using query string parameters. um using url pass parameters. android code , works fine.
public jsonupdate(string jobnumber, string documenttype, string documentfilepath, string documentfilename, string encodedimage, string url) { this.url = url + jobnumber.trim() + "/" + documenttype.trim() + "/" + documentfilepath.trim().replace("/", "___") + "/" + documentfilename.trim() + "/" + encodedimage; } public boolean updateservice() { boolean result = false; httpclient httpclient = new defaulthttpclient(); try { httppost httppost = new httppost(this.url); try { httpresponse httpresponse = httpclient.execute(httppost); if (httpresponse != null) { if (httpresponse.getstatusline().getstatuscode() == 200) result = true; } } catch (clientprotocolexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } } catch (exception ex) { string p = ex.getlocalizedmessage(); string y = ex.getmessage(); } if (!result) { } return result; }
in wcf implementation works fine except whenever include encoded string parameter throws error because encoded string contains '+' , '\'. url getting broken. wcf code service
[webinvoke(method = "post", responseformat = webmessageformat.json, uritemplate = "attachment/{jobnumber}/{documenttype}/{documentfilepath}/{documentfilename}/{encodedimage}", bodystyle = webmessagebodystyle.bare)] public bool insertattachment(string jobnumber, string documenttype, string documentfilepath, string documentfilename, string encodedimage = null) { //implementation written }
how pass encoded 64 bit string safely parameter + , \ ? not have experience on it. b grateful if can give me suggestion.
try android base64 implementation aviable since api 8.
base64.encodetostring(youtstring.getbytes(...), base64.no_wrap + base64.url_safe);
Comments
Post a Comment