Team leader asked me to post some data in other website. I am struggling to do that but it did not work.
XML file must be like this:
<?xml version="1.0" encoding="utf-8"?> <LOGGING> <logging_type>RealData</logging_type> <vender_id>vender id</vender_id> <vender>vender name</vender> <station_ref></station_ref> <station_id>station id</station_id> <station_name></station_name> <send_date> <year>2015</year> <month>08</month> <day>21</day> </send_date> <send_time> <hour>11</hour> <minute>12</minute> <second>13</second> </send_time> <update_date> <year>2015</year> <month>80</month> <day>21</day> </update_date> <update_time> <hour>12</hour> <minute>11</minute> <second>11</second> </update_time> <total_data>29</total_data> …………………………………….…. <status> <message>Complete</message> </status> </LOGGING>
He gave me url of the website which is "http://infomech.selfip.com/infomech/real_data" and he gave the station name and reference id as well. I have coded this:
System.Net.WebRequest req = null; System.Net.WebResponse res = null; try { string uri = txtURL.Text; req = System.Net.WebRequest.Create(uri); req.Method = "POST"; req.ContentType = "text/xml"; System.IO.StreamWriter writer = new System.IO.StreamWriter(req.GetRequestStream()); writer.Write(txtSend.Text); writer.Close(); res.GetResponseStream(); } catch { throw; } finally { if (req != null) req.GetRequestStream().Close(); if (res != null) res.GetResponseStream().Close(); } }
but it does not work. How to do?
No comments:
Post a Comment