BANGALORE, INDIA: Web services are applications through which one can provide different kinds of online services to the web user. These services are hosted on the Internet and can be accessed by authorized users to embedded on their web site. There are a number of web service providers such as Google that provide a host of web services: for eg, the Google search engine can be incorporated into your web site.
Windows Live is another such service that lets you incorporate Windows Live Services to your web site, Windows Live Contact Service shows users' contact list, Windows Live Messenger allows for chatting within the Internet browser and authentication with Windows Live ID. Another example is 'Amazon.com' that allows you to develop a customized application which can search details of products without even visiting the website.
|
Direct Hit!
|
Applies To: Web developers
USP: Learn how to become a web service provider
Primary Link: msdn.microsoft.com
Keywords:ASP.NET AJAX web services |
So, why should you implement web services within your website. Well, they reduce your time and effort spent in doing the same job twice and making things a lot easier for visitors to the website. For example if you want to show the local weather report on your website it won't be feasible for you to stand under the open sky and study weather patterns. On top of it, you'll have to update the temperature continuously on your web site. So, what you can do instead is to have a weather status widget on your website so that you can use the service provided by any weather reporting website to your own website.
Likewise you can have a currency converter within your website which takes the currency value right from the local stock exchange. Web Services works on three different platforms:
1. SOAP: Simple Object Access Protocol is based on XML and is both language and platform independent.
2. WSDL:Web Service Description Language which is also based on the XML but is basically used to describe the web service and how you can access it.
3. UDDI: Universal Description, Discovery and Integration is a directory service that is used where one can register and then search for web services. UDDI uses SOAP to communicate and is built into the MS .NET platform.
Now let's see how you can make your own web service in ASP.NET AJAX and also how you can make use of it at the client side. For creating this we shall use Visual Web Developer 2008. Start with creating a new web service and click on File > New Web Site and select the ASP.NET web service template. Now click on the browse button. Select the local IIS tab on the left hand side and then add a new web service to it.
Give a meaningful name to the web service and click on 'Ok'. As soon as the development environment gets ready, you shall see a web service automatically created. Delete the pre-created service and start the process for creating your own web service. For deleting, right click on the 'service.asmx' file listed on the right side; also delete the code associated with 'service.asmx', i.e. the 'service.vb' file. Now create a new web service by right clicking on the website and then click on 'Add new' item; select the web service option, give a suitable name and click on Add.
|

|
|
In Solution Explorer window, open the Service.asmx file. In the code that shows up, change the class name to pcquest.webservice.service'
|
Once the new service has been added, find the line:
To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line:
'<System.Web.Script.Services.
ScriptService()>