I try passing an array of objects from my webservice in 2008 VS c# to an ASP c# client. What construction is easiest? I'm happy with anything that manage to pass an array objects containing one integer and a few strings.
I would like to use foreach constructs or similar at client (to keep it simple for clients).
I tried to use Dictionary class I quickly found out that Dictionary<key,object> doesn't serialize ( why not is beyond my imagination - it's a bit like designing a car but forget to include a steeringwheel )
So I tried to use
XML Serializable Generic Dictionary from http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx
However the client doesn't get back data even if I see when debugging that inside the webservice, blogs variable is successfully populated. Not sure if I need to call WriteXML /ReadXML myself?
------------------ Server Code
[WebMethod]public SerializableDictionary<int, BlogItem> SearchFreeTextBlog(string SearchText)
{
SerializableDictionary<int, BlogItem> blogs = new SerializableDictionary<int, BlogItem>();
blogs = DBSearchBlogs(SearchText);
return blogs;
}
------ client code
WebServiceBlog2.Service serviceBlog = new WebServiceBlog2.Service();
// commented out: SerializableDictionary<int, BlogItem> blogs = new SerializableDictionary<int, BlogItem>();DataSet blogs = serviceBlog.SearchFreeTextBlog("asp.net");
// Web service returns a SerializableDictionary<int, BlogItem> , but client code compile only if using a DataSet , why?
System.
Console.Write( blogs.ToString() ); // blog is empty at client
GridViewBlogs.DataSource = blogs; // exception "The IListSource does not contain any data sources."
Thanks a million!
QA4Ever