Hi All,
I want to return Large amount of data From wcf web service in XML format. I used return type XMLDocument, but IT is giving error : "This operation is not supported in the WCF Test Client because it uses type system.object[]"
below is my code:
public XmlDocument GetMasterData(double TerritoryCode, double RegionCode, double ZoneCode)
{
SqlConnection conn = new SqlConnection(path_jnj);
SqlCommand cmd;
XmlDocument doc = new XmlDocument();
try
{
cmd = new SqlCommand("GetMastersForAPK", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@TerritoryCode", TerritoryCode);
cmd.Parameters.AddWithValue("@RegionCode", RegionCode);
cmd.Parameters.AddWithValue("@ZoneCode", ZoneCode);
DataTable dtRDS = new DataTable();
SqlDataAdapter daRDS = new SqlDataAdapter();
daRDS.SelectCommand = cmd;
daRDS.Fill(dtRDS);
XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);
doc.AppendChild(dec);
XmlElement root = doc.CreateElement("JNJ");
doc.AppendChild(root);
XmlNode chnode1, chnode2, chnode3, chnode4, chnode5, chnode6, chnode7, chnode8, chnode9, chnode10;
foreach (DataRow row in dtRDS.Rows)
{
chnode1 = doc.CreateNode("element", "SAPID", "");
chnode1.InnerText = row[0].ToString();
root = doc.DocumentElement;
root.AppendChild(chnode1);
chnode2 = doc.CreateNode("element", "CustomerName", "");
chnode2.InnerText = row[2].ToString();
root = doc.DocumentElement;
root.AppendChild(chnode2);
chnode3 = doc.CreateNode("element", "SMCode", "");
chnode3.InnerText = row[4].ToString();
root = doc.DocumentElement;
root.AppendChild(chnode3);
chnode4 = doc.CreateNode("element", "SMName", "");
chnode4.InnerText = row[6].ToString();
root = doc.DocumentElement;
root.AppendChild(chnode4);
chnode5 = doc.CreateNode("element", "RMCode", "");
chnode5.InnerText = row[8].ToString();
root = doc.DocumentElement;
root.AppendChild(chnode5);
chnode6 = doc.CreateNode("element", "RMName", "");
chnode6.InnerText = row[10].ToString();
root = doc.DocumentElement;
root.AppendChild(chnode6);
chnode7 = doc.CreateNode("element", "RtrId", "");
chnode7.InnerText = row[12].ToString();
root = doc.DocumentElement;
root.AppendChild(chnode7);
chnode8 = doc.CreateNode("element", "RtrName", "");
chnode8.InnerText = row[14].ToString();
root = doc.DocumentElement;
root.AppendChild(chnode8);
chnode9 = doc.CreateNode("element", "RtrCategoryCode", "");
chnode9.InnerText = row[16].ToString();
root = doc.DocumentElement;
root.AppendChild(chnode9);
chnode10 = doc.CreateNode("element", "ClassDesc", "");
chnode10.InnerText = row[18].ToString();
root = doc.DocumentElement;
root.AppendChild(chnode10);
}
}
catch (FaultException Fex)
{}
return doc;
}
please provide me solution.
Thanks in Advance