i trying response xml uidai data centers sending xml document using httpwebrequest , receiving using httpwebresponse in c#asp.net web based application. checked using java application , working fine on side web based application throwing exception
an exception of type 'system.net.webexception' occurred in system.dll not handled in user code
note:the web exception occurs on 5th line last
please suggest methods resolve
public void sendforauthentication()//user defined function sending , receiving requests { string url = "http://auth.uidai.gov.in/1.6/public/9/9/mltbkycsgymq1zgl3wmzyrnyvsarlljxpom2a-qtpc0zud23shpnqpk";//the host address streamreader sr1 = new streamreader("d:\\test-signed.xml");//loading xml file stream string xmldata = sr1.readtoend(); string conn = @"<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes""?>"; xmldata = conn + xmldata; httpwebrequest req = (httpwebrequest)webrequest.create(url); byte[] requestbytes = system.text.encoding.utf8.getbytes(xmldata); req.method = "post"; req.contenttype = "text/xml;charset=utf-8"; req.contentlength = requestbytes.length; stream requeststream = req.getrequeststream(); requeststream.write(requestbytes, 0, requestbytes.length); requeststream.close(); httpwebresponse response = (httpwebresponse)req.getresponse();//**here getting webexception** streamreader sr = new streamreader(response.getresponsestream(), system.text.encoding.default); string backstr = sr.readtoend(); reader.readtofollowing("title"); file.writealltext("d:\\xml.xml", backstr); } edit: exception "the operation has timed out" though had increased operation time
edit2: above code works fine there problem firewall
Comments
Post a Comment