c# - Response returning html code instead of XML -
i sending xml data using http post specified url.expected response in xml format. receiving html code instead of xml.i sending sample post code.
string postdata = null; postdata = "netconnect_transaction=" + system.web.httputility.urlencode(xdoc.tostring()); httpwebrequest experianrequest = (httpwebrequest)webrequest.create("some url"); experianrequest.method = "post"; experianrequest.contenttype = "application/x-www-form-urlencoded"; string useridformated = "username:password"; experianrequest.headers.add("authorization: basic" + converttobase64string(useridformated)); experianrequest.timeout = 100000; experianrequest.keepalive = false; experianrequest.credentials = system.net.credentialcache.defaultcredentials; system.text.asciiencoding encoding = new asciiencoding(); byte[] bytedata; bytedata = encoding.getbytes(postdata); experianrequest.allowautoredirect = true; experianrequest.contentlength = bytedata.length; stream newstream = experianrequest.getrequeststream(); newstream.write(bytedata, 0, bytedata.length); newstream.close(); httpwebresponse experianresponse = (httpwebresponse)experianrequest.getresponse(); streamreader reader = new streamreader(experianresponse.getresponsestream(), encoding.utf8); //xmltextreader objxml = new xmltextreader(newstream2); //xmldocument xdocresponse = new xmldocument(); //xdocresponse.load(experianresponse.getresponsestream()); //string root = xdocresponse.documentelement.outerxml; //xdocument xdocresponse = xdocument.load(objxml); //objxml.close(); //experianresponse.close(); //streamreader reader = new streamreader(newstream2); string responsefromserver = reader.readtoend(); reader.close(); //newstream.close(); experianresponse.close();
Comments
Post a Comment