How to create and use Web services

Source: Internet
Author: User
Brief 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 that a Web site provides for other Web sites to invoke. For example, a financial company can provide a detailed stock quote to its trading partner through a Web service that can be read and displayed through a Web page, or read from a client's desktop application.
This article describes two aspects of Web services: How to create a Web service, and how to use a Web service. As an example, we explain how to create a Web service with a Web service from the FAQs (FAQ) of aspfaqs.com (http://www.aspfaqs.com/aspfaqs/).
Creating a Web Service
Before you create a Web service, you must first ask yourself: "What services do I offer to my users?" ”。 The goal of this article is to create a Web service that lets other users display a list of frequently asked questions (FAQS) from aspfaqs.com on their own web site. The ideal function is to limit other sites to view FAQs categories and FAQs, and if you want to see an answer to a question, let the user visit the site that provides the service http://www.aspfaqs.com. The Web services in this article will ultimately provide the following features to other Web sites: 1, browse through the list of all FAQ categories
2, browse all the FAQs in a particular category.
3, browse a question for a FAQ, but don't include an answer.
Creating a Web service is simple, creating an. asmx file first (you can use Visual Studio.) NET or any text editor you like, it is recommended to use the Web Matrix, it has a template for creating Web services, and Web services are created as a common class, and there is a macro in front of the method that indicates that this method is accessed through a Web service.
In the case of aspfaqs.com Web services, first create three methods to access through Web services, GetCategories, Getfaqsincategory, and Getfaq, respectively, to implement the tasks described above 1,2,3. and create a private method GetDataSet, which is assembled into a dataset by the SQL query passed over. Here is the implementation code:
Imports System.Web.Services
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.