ASP. NET + Web Services for software sharing

Source: Internet
Author: User

AbstractThis paper proposes a new method to share software functions by sharing software functions. The advantage of this method is to share software functions by remotely calling Web Services, without copying the software to the client, it also reduces some resource redundancy on the network and facilitates the integration of existing Web services into new systems. In addition, the effectiveness of this new method is analyzed through examples of the student identity verification module.


  Introduction

Traditional software sharing involves copying software from a network server to a client to share the software. The disadvantage of this method is that every client that needs to use the software must first copy the software, leading to space redundancy on the network, resulting in a large amount of Isolated Data and duplicate business logic.

Web services enables data exchange and remote application logic calls by using XML Message Processing, enabling data to move data between heterogeneous systems through the firewall, it provides a feasible solution for achieving data and system interoperability.

This article proposes a new method to achieve software sharing by sharing software functions. The advantage of this method is to share software functions by remotely calling Web Services, without copying the software to the client, it also reduces some resource redundancy on the network and facilitates the integration of existing Web services into new systems. In addition, the effectiveness of this new method is analyzed through examples of the student identity verification module.

  Significance of software sharing

With the popularization and development of computer applications, as many as various industries, as many as a company and department have developed and applied practical computer software. These software greatly improves the work efficiency and modernization management level of the company, and has become the core of the company's business operation and management. However, most companies generally use custom software in almost every department, resulting in a large number of practical but isolated and repetitive business logic blocks. If you can avoid repeated design during design and development, but share software functions to achieve the same functions of each module, it will greatly save software development costs, it also provides a good framework for future system upgrades and integration. In addition, for existing business logic, a small number of improvements can be made to be shared by other applications, thus reducing development costs.

Because the development of each application is in a variety of environments, and technology is constantly evolving, sharing an existing application to create a function set is very difficult in the past. Fortunately, the emergence of Web Services technology provides the possibility for the implementation of software sharing. The Web service of software functions provides the business logic that can be shared over the Internet, finally, an open functional component system based on various Web services is formed. Next, we will discuss how to use Web Services technology to achieve software sharing.

  Software sharing based on Web Services technology

1. Introduction to Web Services

Web Services can be seen as an API deployed on the Internet. It can be easily integrated and called by applications and other Web Services to form a new application service. It is well-encapsulated, loosely coupled, and highly integrated. There is no doubt that the Web Services technology will become the mainstream technology of the next generation of Web, which is the embodiment of "software as a service.

The architecture of Web Services is as follows, which consists of service requestor, Service proxy, and service provider:


A Web service provider is the owner of a Web Service. It registers with the Service proxy to configure and publish services, and patiently waits for other services and users to provide their own functions; the Web service requestor is the user of the Web function. It uses the search operation to retrieve the service description from the Service proxy, and then binds to the service provider and calls the Web service or interacts with it.
A Web service provider is equivalent to an intermediary. It associates a Web service requestor with a suitable Web service provider, typically UDDI, UDDI provides a mechanism for service requestors to dynamically search for Web Services.

2. Implementation of Software sharing based on Web Services

During software development, software is often divided into different modules based on functions to facilitate re-use and modification and upgrade of module functions. To achieve software sharing through Web Services, you also need to divide the integrated system into modules by function. Then, you need to create Web Services to implement these functional modules. In order to make Web Services accessible, you also need to publish the service description (deploy the Web Service) so that other modules can find and call it. In this way, software functions implemented using Web services can be shared by applications and even other Web Services.

When the application or other Web services and other service requestor need to call the Web service, they first retrieve the service description or query the required service type in the service registration center. When finding the desired service, you can use the service description to bind it to the service provider and call the corresponding service.

Microsoft's new flagship product Visual Studio. NET is the preferred tool for developing Web Services. Using Visual Studio. NET can easily create and call Web Services. The following describes an example of software sharing based on Web Services.
3. Application Example of software sharing: Implementation of the student identity verification module.

Currently, there are many software systems in colleges and universities, such as course selection system, score query system, online course system, library system, and student financial system. Because each system is independent of each other, each system has a student identity verification module, which is designed with repeated functions. In addition, each system is independent of each other, there are passwords that students need to remember for different systems.

In view of the above situation and the current highly developed campus network, we can use Web services to share the student identity verification module. The following describes how to use the Visual Studio. NET environment to create and call the Student Identity Authentication Web Service in the C # language.

1) create a Web Service

The student identity authentication module consists of one Web Service:

Public Boolean ValidUser (string userID, string Pwd)

The Web Service ValidUser is used to verify the Student Identity. A Student basic info table Student has been created in the SQL Server database StudentsInfo. the UserID and Pwd fields respectively Save the Student's user code and password.

The following describes how to create a Web service:

A. Run the Visual Studio. NET development environment to create a "ASP. NET Web service" type project WSStudentLogin.

The specific code implementation of B Web service.

 
Using System. Data. SqlClient;
// Omitting the code ......
Public class Service1: System. Web. Services. WebService
{
String ConStr = ";
ConnStr = "DATABASE = StudentsInfo; SERVER = 10.1.111.19; UID = sa; PWD = ;";
// Omitting the code ......
[WebMethod]
Public Boolean ValidUser (string userID, string Pwd)
{
Boolean flag = false;
String sqlStr = ";
// Create a database connection object
SqlConnection tempConn = new SqlConnection (ConnStr );
SqlStr = "select * from student where ID = '" + userID + "' and pwd = '" + Pwd + "';";
// Create a command object
SqlCommand tempComm = new SqlCommand (sqlStr, tempConn );
TempConn. Open ();
SqlDataReader tempReader = tempComm. ExecuteReader (CommandBehavior. CloseConnection );
If (tempReader. HasRows) flag = true;
TempReader. Close ();
TempComm. Dispose ();
Return flag;
}
}

Note that only the methods described in [WebMethod] are Web services that can be remotely called. Therefore, the [WebMethod] before the method cannot be omitted.

To make Web services accessible to others, you must deploy them to the Web server that you want to support. To deploy a Web service to a server other than the development server, you can add a Web installation project or copy the required files to the target server. Due to space limitations, this article does not discuss this in depth. Assume that the Web service in this example is deployed on the development server.

After creating and deploying a Web service, we can call the corresponding Web service on the client. The following describes how to locate and reference Web services on the client.

2) Web service call

The process of using Web Services is actually the process of binding Web service users to Web Services and calling their methods. To simplify the binding process. Visual Studio. NET provides the service proxy class method. The Service proxy class is a local class generated according to the Web Service Description document (XXX. WSDL). During the execution, the customer uses the information in the proxy class to access the Web Service and call the actual method. Visual Studio. NET provides a simple way to implement this process:

A. Create a Web service to access the client program.

Web Service Access to customer programs can be various types of applications or other Web Services. Here, we create a "ASP. net web application" type project WebApplication2.

B. Service reference.

First, click "add Web reference" on the "project" menu ". Next, because the Web service in this example is located on the local computer, click the "Web Service on the Local Computer" link in the browser pane. Then, click the Service1 link from the provided list to retrieve information about the Web service. Then, click "add reference" to add a Web reference to the target Web service. Visual Studio. NET downloads the service description and generates a proxy class that acts as an interface between the application and the Web service.

C. Sample Code for calling Web Services in a client program.

Private void button#click (object sender, System. EventArgs e)
{// Create a proxy object
Localhost. Service1 ClientProxy = new localhost. Service1 ();
Try
{// Access the Web service through code objects
If (ClientProxy. ValidUser (TxtUserId. Text, txtPwd. Text ))
Label1.Text = "OK ";
Else
Label1.Text = "ERROR ";
}
Catch (e)
{Throw e ;}
Finally
{ClientProxy. Dispose ();}
}

Others

The Web Services technology provides a good technical basis for software sharing and system integration based on existing information systems. However, software sharing based on Web Service technology must be truly practical. We also need to solve the following problems: first, security and reliability, first, the connection reliability of Web service network transmission, and second, the reliability of Web service content, that is, ensuring data integrity and confidentiality. The second is Service permission control. Web services are the embodiment of "software as a service". Who is prohibited from using this service and who is allowed to use this service, how to use this service to charge fees is a problem that needs to be solved in actual use. In addition, problems such as the bearing capacity of Web Services, deployment and discovery of Web Services, and failure handling of customer calls to Web services also need to be solved.

Summary

This article proposes how to share software functions from the perspective of software function sharing, and discusses the use of Web Services technology to achieve remote software function sharing, the student body verification module is used to analyze the effectiveness and advantages of software function sharing. The Research on software function sharing is of great significance for Distributed Computing and so on. It also needs further research.

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.