I have recently been learning Silverlight for some work projects and decided to try and integrate .XAP files directly into WordPress blog posts using Silverlight for WordPress by Tim Heuer (of timheuer.com fame :-))
Simple enough install but had then ran into the issue with Silverlight cross domain web service calls. If the web service you are trying to call from Silverlight doesn’t have the crossdomain.xml file (Google it for specifics) at the web host root asynchronous Silverlight methods fail upon completion. As I wanted to call a weather API this was an issue. Instead I loaded the crossdomain.xml file onto my own web host and created a quick and dirty PHP page to parse the Secret Google weather web service. This was then called by the Silverlight .XAP as can be seen below (it tells you what the current temperature is in my home town of Cambridge, UK). Easy :-).
Public Sub New() InitializeComponent() Dim wc As New WebClient() Dim baseURI As String = "http://www.muacksandglomps.com/Weather.php" AddHandler wc.DownloadStringCompleted, AddressOf completed wc.DownloadStringAsync(New Uri(baseURI)) End Sub Private Sub completed(sender As Object, e As DownloadStringCompletedEventArgs) WeatherTextBlock.Text = "It is " & e.Result & "°C in Cambridge" End Sub
Next up something more complicated……
Edit: Just noticed that the Silverlight for WordPress plugin by Tim Heuer only works if the posts are viewed on the front page not as a stand alone post. Changed the plugin to the Simply Silverlight plugin by DigitalWindFire. Everything now works again and it even has more fetures.