Introduction
In the first and second part of this tutorial on xml-script we introduced the declarative programming model and illustrated how to handle events raised by the client Microsoft Ajax objects. Events can be handled by invoking a global JavaScript function or by using actions; in this third part we'll talk about the InvokeMethod action, which allows calling a method declaratively.
InvokeMethod Action
The InvokeMethod action enables invoking a method exposed in the type descriptor of a client object. In the following example, we'll illustrate this action with the help of an interesting class contained in the Futures CTP: Sys.Preview.Net.ServiceMethodRequest. This class abstracts an asynchronous call to a web service method and exposes a type descriptor that allows using it in xml-script. This means that we can invoke a web method and process its results without writing a single line of JavaScript.
The example
To keep things simple, we will poll (i.e. call at regular intervals) a web method that returns the current time on the web server; then, we'll display it on a label.