Improve your contact center performance. See how you can make a difference.
Watch Now
Engage and build your ICT audience with CIOL online advertising.
Know more
You need additional attributes to use this web service, so 'uncomment' the above line. Now we shall explicitly mention the namespace and keep every single code inside this namespace. An example of the code is shown below:
Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols Namespace pcquest.webservice 'all the code inside this section End Namespace
After this double click on the 'service.asmx' file and replace the class name service with the name of the namespace i.e. pcquest.webservice. The line in service.asmx file should like this:
?<%@ WebService Language="vb" CodeBehind="~/App_Code/Service.vb" Class="pcquest.webservice" %>?
Once this is done, right click on the service.asmx file and view it on Internet Explorer. It should show the web service page; click on the invoke button on the web page to test the web service.
Now it's time for client side coding. For this close the current Web Developer 2008 project and start a fresh project. This time we will be creating a new ASP.NET AJAX website. Provide a suitable name and click on Ok. As the page appears we see a couple of standard code already written.
We shall modify those codes according to our needs. First give a title to your web page, for eg, 'Website for testing web services' and then delete everything that is inside the 'Body' tag. Place the following code inside the body:
<form id="form1" runat = "server"> <asp:ScriptManager runat = "server"> <Services> <asp:ServiceReference Path = "http://localhost/webservice/Service.asmx" /> </Services> </asp:ScriptManager> <button id="hello" onclick = "callservice()"> Click </button> </form>
And in the 'head' tag place these two functions:
<script type ="text/javascript"> function callservice () {pcquest.webservice.service.hello (callcomplete) } function callcomplete(textrecived) { alert(textrecived ) } </script>
And that's all, save your project and view your client web page on the web browser. Now click on the button which is on the web page and you will get an alert which says 'Hello'. Similarly you can use this to retrieve the status of some process or project. Web services can also be used to retrieve any data from the database and deliver the required data to the client side.
<< PREVIOUS