Client Agent Analysis
• Each Service class corresponds to a proxy class on the client.
• Each proxy class is a subclass of the SYS. net. webserviceproxy class.
• Each method of the proxy class corresponds to a static method of the class
• Finally, the request is sent by the SYS. net. webserviceproxy. Invoke method.
Aspx < Form ID = " Form1 " Runat = " Server " >
< ASP: scriptmanager ID = " Scriptmanager1 " Runat = " Server " Scriptmode = " Debug " />
< Input type = " Button " Value = " Get range random " Onclick = " Getrandom (1, 50,100) " />
< Script Language = " Javascript " Type = " Text/JavaScript " >
Function getrandom (minvalue, maxvalue)
{
SYS. net. webserviceproxy. Invoke (
" Services/usehttpgetservice. asmx " ,
" Getrangerandom " ,
True ,
{ " Minvalue " : Minvalue,
" Maxvalue " : Maxvalue },
Onsucceeded,
Null ,
Null ,
- 1 );
}
Function onsucceeded (result)
{
Alert (result );
}
</ Script >
</ Form >
The inlinescript = "true" of scriptmanager is not called by using the SYS. net. webserviceproxy. Invoke method instead of the client proxy.
usehttpgetservice. asmx <% @ WebService language = " C # " class = " usehttpgetservice " %>
UsingSystem;
UsingSystem. Web;
UsingSystem. Web. Services;
UsingSystem. Web. Services. Protocols;
UsingSystem. Web. Script. Services;
[WebService (namespace = " Http://tempuri.org/ " )]
[Webservicebinding (conformsto = Wsiprofiles. basicprofile1_1)]
[Scriptservice]
Public Class Usehttpgetservice: system. Web. Services. WebService
{
[Webmethod]
Public Int Getrandom ()
{
Return New random (datetime. Now. millisecond). Next ();
}
[Webmethod]
[Scriptmethod (usehttpget=True)]
Public IntGetrangerandom (IntMinvalue,IntMaxvalue)
{
Return NewRandom (datetime. Now. millisecond). Next (minvalue, maxvalue );
}
}