Introduction
One of the most powerful aspects of. NET is that it can be used to create Web Services. A Web Service is an external interface provided by a website for calls by other websites. For example, a financial company can provide detailed stock quotations with its trading partners through Web services. Such information can be read and displayed on the Web page, it can also be read from customers' desktop applications.
This article describes two aspects of Web Services: How to Create Web services and how to use Web services. As an example, we have since ASPFAQs.com (http://www.aspfaqs.com/aspfaqs/) FAQS (FAQ) Web services to explain how to create a Web service.
Create a Web Service
Before creating a Web service, you must first ask yourself: "What services do I want to provide to my users ?". The goal of this article is to create a Web service that allows other users to display a list of FAQ (FAQS) from ASPFAQs.com on their own websites. The ideal function is to restrict other websites to only view FAQS categories and FAQS by category. If you want to view the answer to a question, it allows users to access the http://www.aspfaqs.com of the website that provides services. The Web service in this example provides the following functions to other websites: 1. view the list of all FAQ categories.
2. Browse all FAQS in a category.
3. Browse a FAQ, but do not include answers.
It is easy to create a Web service. First, create a Web service. asmx file (you can use Visual Studio. NET or any text editor you like. We recommend that you use Web Matrix, which has templates for creating Web services.) Web services are created as common classes, there is a macro in front of the method, indicating that this method is accessed through Web Services.
For the ASPFAQS.com Web service, first create three methods for access through the Web service, GetCategories, GetFAQsInCategory, and GetFAQ, respectively to implement the preceding tasks 1, 2, 3. Create a private method GetDataSet and assemble it into a DataSet Based on the passed SQL query. The following is the implementation code:
Imports System. Web. Services
Imports System. Data
Imports System. Data. SqlClient
Imports System. Configuration