This allows the json representation for that web service method to be returned and included by a script line like this.
<script type="text/javascript" language="JavaScript" src="SimpleService.asmx/js">
When you view the contents of the script, you will get something like the following.
Type.registerNamespace('Quickstart.Samples'); Quickstart.Samples.SimpleService =
{ path: "/quickstart/atlas/samples/services/SimpleService.asmx",
EchoString:function(s,onMethodComplete, onMethodTimeout)
{return Web.Net.ServiceMethodRequest.callMethod(this.path,
"EchoString",{s:s}, onMethodComplete, onMethodTimeout); } }
This basically makes calls into the Atlas core javascript libaries which know how to call a web service asynchronously. The atlas core libraries are included by these lines.
<atlas:Script ID="Script1" runat="server" Path="~/ScriptLibrary/AtlasCompat.js"
Browser="Mozilla" />
<atlas:Script ID="Script2" runat="server" Path="~/ScriptLibrary/AtlasCompat.js"
Browser="Firefox" />
<atlas:Script ID="Script3" runat="server"
Path="~/ScriptLibrary/AtlasRuntime.js"/>
Once you have all of that you can just write a javascript method that calls the web service, passing it the input values, an event to call on completion and timeout.
requestSimpleService = Quickstart.Samples.SimpleService.EchoString(
"SomeText", //params
OnComplete, //Complete event
OnTimeout //Timeout event
);
That really is all that is to it. If you want to see a working example, try the link below.
If you have not installed the templates yet for it, be sure and do so at the link below.
Read the complete post at http://www.dotnettipoftheday.com/blog.aspx?id=47