I'm wanting my WEB API method to return an XML object back to the calling application. Currently it's just returning the XML as a string object. Is this a no no? If so how do you tell the webapi get method that it's returning an object of type XML?
Thanks
Edit: An example of the Get method:
[AcceptVerbs("GET")]
public HttpResponseMessage Get(int tenantID, string dataType, string ActionName)
{
List<string> SQLResult = MyWebSite_DataProvidor.DB.spReturnXMLData
("SELECT * FROM vwContactListing FOR XML AUTO, ELEMENTS").ToList();
string AllResults = "";
for (int i = 0; i < SQLResult.Count - 1; i++)
{
AllResults += SQLResult[i];
}
string sSyncData = "<?xml version="1.0"?> " + AllResults;
HttpResponseMessage response = new HttpResponseMessage();
response.Content = new StringContent(sSyncData);
return response;
}
Its a bit hacky because im still at the prototyping stage. Will refactor when i can prove its doable.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…