This post gives you an idea how to return IEnumerable object in your XML web services, the tip for this post is how to convert this IEnumerable object to something that can be serialized in your xml web serivces.
If you are using LINQ in your xml web serivces, below is an example for the signature of your xml web service:
[WebMethod]
public IEnumerable
{
return logic.ListUser();
}
If you run this xml web service, you will get this error :
"Cannot serialize interface System.Collections.Generic.IEnumerable"
To solve this problem, simply convert the IEnumerable Object to Array using ToArray() extension method.
[WebMethod]
public TwitterUser[] ListUser()
{
return logic.ListUser().ToArray();
}
This will fix this problem and return the result as XML in your xml web service.
Hope this helps.
Regards,
Mostafa arafa
1 comment:
thanks alot, this solved my problem!
Post a Comment