Wednesday, 2 October 2013

Webservice(asmx) returns array, not list

Webservice(asmx) returns array, not list

I have a deserialization webmethod which returns a list of data in
webservice(asmx), and I am calling the method from client-side. However,
the method is giving me an array, not a list. I understand that it is
because of SOAP response which returns xml format (or something like
that..)
Is it possible to return a list? If then, please tell me an idea.
If not, please teach me an alternative way. (I should not use array...)
service.asmx.cs
[WebMethod]
public IList<Person> DeserializeJson(string value)
{
JavaScriptSerializer js = new JavaScriptSerializer();
IList<Person> tableData = js.Deserialize<IList<Person>>(value);
return tableData;
}
Client.aspx.cs (WebService is my service reference)
WebService.Service1SoapClient client = new WebService.Service1SoapClient();
string stream = client.CreateJsonFromDatabase();
List<WebService.Person> tableData = client.DeserializeJson(stream);

No comments:

Post a Comment