How to create and use Web Services

Source: Internet
Author: User

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

Related Article

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.