Today we discussed consuming Web Services in our Silverlight 2 applications using ASMX Web Services, WCF Services and REST. This webcast was based on a blogpost by Tim Heuer. The attached code is modified from his source code to work with Silverlight 2 Beta 2. The changes I made from his code are as follows:
- In the CallingServices Silverlight Project I added a reference to System.Net
- I changed the startup project to CallingServices_Web and the startup page to CallingServicesTestPage.aspx
- In the Bin folder of the CallingServices_Web project I updated the path of the System.Web.Silverlight.dll.refresh item to point to my local silverlight.dll (as I'm running Vista 64-bit, it's saved to my Program Files x86 folder)
- In Page.xaml of my CallingServices Silverlight project, I all references to System.Windows.Controls, which included removing the text below from the UserControl xaml element and removing "Controls:" from the beginning and ending <Button> tags
- I added my Flickr API Key in the URI for my Rest button implementation.
Here are the links I referenced:
Tim Heuer's blogpost on Web Services in Silverlight: http://timheuer.com/blog/archive/2008/03/14/calling-web-services-with-silverlight-2.aspx and follow up: http://timheuer.com/blog/archive/2008/03/19/calling-services-with-silverlight-part-2.aspx
A great explanation of when and how to use WebClient or HttpWebRequest in Silverlight: http://www.silverlightshow.net/items/Using-WebClient-and-HttpWebRequest.aspx
Tim's videos on Web Services from Silverlight.net/learn. There are 3 videos - one one WCF, one on Cross Domain networking, and one focusing on WebClient/HttpWebRequest usage: http://silverlight.net/learn/videocat.aspx?cat=2#HDI2WebServices
Please let me know if you have any questions! See you on Wednesday for Unit Testing!