Up to this point, we have created the Web service that we
will use later on to show detailed information on the clickable areas on the
image map we are developing. However, for the client side script to be able to
make successful calls for the Web service, we need to add a new ScriptManager
on the page and add the Web service in the Service Reference section.
The code below shows how the ScriptManager is configured by
a Service Reference entry:
Listing 4
<asp:ScriptManager ID="ScriptManager1" runat="server">
<services>
<asp:servicereference path="~/LocationService.asmx" />
</services>
</asp:ScriptManager>
All that is need to do to enable script-service calls in an
asynchronous fashion, is simply add a new service reference entry into the
ScriptManager control as shown in the code above.
What does the above Service Reference entry do?
The configuration above would add something like this to the
rendered page:
Listing 5
<script src="LocationService.asmx/jsdebug" type="text/javascript"></script>
As you can see a new script entry has been added to the
rendered page. The script tag refers to a JavaScript file named
LocationService.asmx/jsdebug. This is called the Web Service Proxy class. The
way AJAX works is by creating client-side proxy classes so that client-side
functions can call the server-side Web service by utilizing this proxy class.
If you simply copy the path shown above into the browser,
you would see a JavaScript file that is generated at run time by the AJAX environment to make script-service calls available. We will not delve into more
details of explaining the proxy class since this is out of the scope of this
article, but checking the above articles that were mentioned in a previous
section would make more sense to you about what we are discussing here.
Up to this point, the page is ready to make script-service
calls successfully!