How to print response that returns from a web service



I'am new at using web services and trying to understand their structure, how they works etc. I found this example from web. Actually i understand what it does. I want to improve this example. What i want to do is print all values that return from this service but don't know what to do. Any guide or suggestion would be appriciated.



public void GetFeeds()
{
WebClient wcXML = new WebClient();
wcXML.OpenReadAsync(new Uri("http://ift.tt/1feoVbJ"));
wcXML.OpenReadCompleted += new OpenReadCompletedEventHandler(wClientUpdate);
}

/// <summary>
/// Web Client Update Read Complete Event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void wClientUpdate(object sender, OpenReadCompletedEventArgs e)
{
if (e.Error == null)
{
try
{
Stream Resultstream = e.Result;
XmlReader reader = XmlReader.Create(Resultstream);
XDocument xDocumentLive = XDocument.Load(reader);
XNamespace ns = "http://ift.tt/1sD7vwL";
List<Feed> feedList = new List<Feed>();
feedList.AddRange((from query in xDocumentLive.Element(ns + "ArrayOfLineStatus").Elements(ns + "LineStatus")
select new Feed
{
Name = (string)query.Element(ns + "Line").Attribute("Name").Value,
Description = (string)query.Element(ns + "Status").Attribute("Description").Value,
isActive = (string)query.Element(ns + "Status").Attribute("IsActive").Value
}).ToList());
}
catch (Exception ex)
{
}
}

No comments:

Post a Comment