visual c++ - & in xml - not able to httppost using CinternetSession -
i trying post xml file using tinyxml , cinternetsession.
what happens when have xml string this:
<url>https://www.google.co.in/#hl=en&sugexp=les%3b&gs_rn=2&gs_ri=hp&cp=8&gs_id=2z&xhr=t&q=test+mail&es_nrs=true&pf=p&tbo=d&output=search&sclient=psy-ab&oq=test+mai&gs_l=&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.&bvm=bv.42080656,d.bmk&fp=21a28671ab5b10f8&biw=1024&</url>
when seek post server cannot so.
text stops @ https://www.google.co.in/#hl=en
this code tried :
tixmldocument docs( c:\\data.xml" ); bool loadokay = docs.loadfile(); if ( loadokay ) { } else { tixmlprinter printer; printer.setindent("\t"); docs.accept( &printer ); docs.print(); cstring urlpostdata = printer.cstr(); #define max_read_buffer 102400 cstring strheaders =_t("content-type: application/x-www-form-urlencoded"); cstring strformdata = _t("data=<?xml version=\"1.0\"?><urldata>"+urlpostdata+"</urldata>"); //afxmessagebox(strformdata); // here got msgbox "&" in data, while posting fails. cinternetsession session; session.setoption(internet_option_connect_timeout,10000); session.setoption(internet_option_connect_retries, 3); chttpconnection* pconnection = session.gethttpconnection(_t("xxx.xxx.xxx.x")); chttpfile* pfile = pconnection->openrequest(chttpconnection::http_verb_post, _t("/wintest/testservlet?")); bool result = pfile->sendrequest(strheaders, (lpvoid)(lpctstr)strformdata, strformdata.getlength()); dword dwerror; pfile->queryinfostatuscode(dwerror); if(dwerror==200) { afxmessagebox("data posted"); } }
my xml file is
<?xml version="1.0" encoding="utf-8"?> <application name="assignments"> <starttime>11/02/2013 16:27:14</starttime> </application>
xml visual-c++ xmlhttprequest http-post tinyxml
No comments:
Post a Comment