Archive

Posts Tagged ‘Coding’

Client-Side Web Service Calls with javascript (AJAX)

March 13th, 2008 No comments
Today i came across a simple method of using webservices as a local function in client side code. It uses the ScriptManager control installed by ASP.NET AJAX-Enabled Web applications.
 
for example you use the followin code to the ASPX to embed the webservice :

 
   
 

 
In javascript you can now the full named webservice:
function OnLookup()
{          
  var stb = document.getElementById(“_symbolTextBox”); 
  MsdnMagazine.StockQuoteService.GetStockQuote(
    stb.value, OnLookupComplete, OnError);
}
 
A very nice feature which makes some nice possiblities.
Read more at:
Categories: Uncategorized Tags: ,

Silverlight 2.0 and network cross domain calls

March 10th, 2008 No comments

After reading Scott Guthries silverlight 2.0 using networking to retrieve data and populate a datagrid tutorial I decided to try and make a little Silverlight 2.0 banner that displays my recent tracks from the Last.FM through their great  webservices with some nifty graphics.

I decided to use the same code as Scott and use the WebClient class to download the xml asynchronously. After implementing and running the code I get a “Security Error” exception on DownloadStringAsync. It appears you have to run the Silverlight app on a hosted HTML on IIS instead of a HTML file on a local drive, pretty strange in my opinion, see silverlight.net for more.

After hosting my html on IIS I get an empty screen, no Exceptions. Scott uses the following code to fill the datagrid after the data is downloaded:

void recentTracksService_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
RecentTrackList.ItemsSource = LastFMServices.Stats.getRecentTraks(e.Result);
}
}

I decided to place a breakpoint on e.Error, and it turned out it did contain an error: “Download Failure”. That’s pretty strange? When using the Digg link from Scotts sample I get data from the webservice. When reading Scotts Blog again I came across the following text: “Silverlight 2 defines an XML policy file format that allows server administrators to precisely control what access a client should have. Silverlight 2 also honors the default Flash cross domain policy file format – which means that you can use Silverlight 2 to call any existing remote REST, SOAP/WS*, RSS, JSON or XML end-point on the web that already enables cross-domain access for Flash clients.

Digg.com has a pretty cool set of Digg APIs that they publish over HTTP. Because they have a Flash cross-domain policy file in place on their server, we can call them directly from our Silverlight Digg client application (and not require us to tunnel back through our web-server to reach their APIs).”

Hmm it appears Last.FM doesn’t honor the Flash cross domain policy file format or the new Microsoft cross domain XML files. I’ll post a request at the Last.FM forum to add those XML files to the server, I hope they’ll allow it.

Read this on: how to make a Service Available Across Domain Boundaries

Some further info on Webservices and Silverlight:
Sending and Receiving Plain XML Messages with Silverlight
WebClient..::.DownloadStringAsync Method (Uri)

Categories: Uncategorized Tags: ,

WPF/XBAP and Media Center = Deprecated

March 7th, 2008 No comments
Me and my colleagues were planning on developing a application to play a WPF application in the Media Center. I have installed the MCE SDK a year ago on my Developing Image. When checking the MCE development site I came across a post that announced a new SDK version. In the changelog:
 
“Deprecated Features:
The following platform features have been deprecated with this release:
Hosting for Microsoft .NET Framework 3.0 Extensible Application Markup Language (XAML) browser applications (XBAPs).
The Triple-tap / Soft-keyboard ActiveX control for hosted HTML applications.
Support for using alternative shells to run and host HTML applications.”
 
Too bad, end of experiment for us, maybe i go to SilverLight 2.0 now ..
 
Read the entire SDK post here:
Categories: Uncategorized Tags: