I am trying to make a web service that returns the list of response from another domain but I am having trouble converting the WebResponse to DataTable so I can return it as a list. So basically the flow is WebResponse -> DataTable -> List
so far I have this
public string getAgentStat()
{
WebRequest request = WebRequest.Create("http://1.1.1.1/test/testweb.dll?Tenant=test&Filter=Calls");
request.Credentials = new NetworkCredential("test@test.com", "P@ssw0rd123");
request.Method = "GET";
WebResponse response = request.GetResponse();
DataTable table = new DataTable();
System.IO.StreamReader stream = new System.IO.StreamReader(response.GetResponseStream());
table.ReadXml(stream);
return stream.ReadToEnd();
}
but I am encountering an error on the code line table.ReadXml(stream)
the error says
DataTable does not support schema inference from Xml
As much as possible I like to do it as fast so avoiding looping in converting the webresponse to Datatable is a must.
Any suggestion is accepted. If you think my way is inefficient.
Edit 1: The list that will be returned
public class test
{
public int cw;
}
static List<test> test_ = new List<test> {};
Edit 2: The XML returned
<QCalls ts="Fri Jan 11 01:30:27 2019 UTC" cts="Fri Jan 11 01:27:03 2019 UTC" tzo="-28800" al="false">
<Q id="1" n="testLo" wt="151516" ch="29" cwt="1635" ct="25" co="29" ca="0" cw="4" awt="56904" act="282" cbh="3" ofi="0" ofo="0" catqos="0" dlro="275">
<internet id="1" n="RetailerLo"/>
<message id="1" n="RetailerLo"/>
<phone id="1" n="RetailerLo" wt="0" ch="22" cwt="23" ct="22" co="22" ca="0" cw="0" awt="0" act="372" cbh="3" ofi="0" ofo="0" catqos="0"/>
<callback id="1" n="RetailerLo" wt="151516" ch="7" cwt="1612" ct="3" co="7" cw="4" awt="56904" act="0" cbh="0"/>
<O id="0" cnt="1"/>
</Q>
<Q id="1" n="testHi" wt="36326" ch="9" cwt="41790" ct="7" co="7" ca="0" cw="1" awt="36326" act="770" cbh="2" ofo="0" catqos="0" dlro="26">
<internet id="1" n="RetailerHi"/>
<message id="1" n="RetailerHi"/>
<phone id="1" n="RetailerHi" wt="0" ch="8" cwt="7" ct="7" co="7" ca="0" cw="0" awt="0" act="866" cbh="2" ofo="0" catqos="0"/>
<callback id="1" n="RetailerHi" wt="36326" ch="1" cwt="41783" ct="0" co="0" cw="1" awt="36326" act="1" cbh="0"/>
<O id="0" cnt="26"/>
</Q>
</QCalls>