ASP. NET + Web Services for software sharing

Source: Internet
Author: User

Abstract This 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 applications by using XML Message ProcessingProgramLogical remote calls enable data to move data between heterogeneous systems through the firewall. This provides a feasible solution for 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 information table student has been created in the SQL Server database studentsinfo, where the field userid and PWD respectively Save the student's userCodeAnd 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 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.

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.