java - How to attach XML file in message body of HTTP post request? -
how attach xml file in message body of http post request?
can 1 give example kind
here sample code snippet making http post request on desired url:
try { string myxml = "<? xml version=1.0> <request> <elemtnt> <data id=\"1\">e1203</data> <data id=\"2\">e1204</data> </element> </request>"; httpclient httpclient = new defaulthttpclient(); httpcontext localcontext = new basichttpcontext(); httppost httppost = new httppost("https://www.google.com/calendar/feeds/default/owncalendars/full"); list<namevaluepair> datatopost = new arraylist<namevaluepair>(); datatopost.add(new basicnamevaluepair("yourxml", myxml)); httppost.setentity(new urlencodedformentity(datatopost)); httpresponse response = httpclient.execute(httppost, localcontext); } catch (exception e) { e.printstacktrace(); }
Comments
Post a Comment