Asp.net+web service realizes software sharing

Source: Internet
Author: User
Tags reference web services client visual studio advantage
Asp.net|web|web Service Summary This paper proposes a new method to realize software sharing through software function sharing, the advantage of which is to share software function in the form of Remote call Web service, without copying software to client, and reducing some resource redundancy on network, It also facilitates the sharing of existing Web services to integrate new systems. And this paper analyzes the effectiveness of this new method through the example of Student authentication module.

Keywords Web services; software sharing; Web Services

Introduction

Traditional software sharing is the copying of software from a network server to a client, to realize the sharing of software, the disadvantage of this approach is that every client that needs to use the software must first copy the software, resulting in space redundancy on the network, resulting in a large amount of isolated data and repetitive business logic.

WEB Services provides a viable solution for data and system interoperability by enabling data exchange and remote invocation of application logic by using XML message processing, enabling data to pass through firewalls and moving data between heterogeneous systems.

In this paper, a new method of software sharing through software sharing is proposed, which has the advantage of sharing software functions in the form of Remote call Web services without copying the software to the client and reducing some resources redundancy on the network. It also facilitates the sharing of existing Web services to integrate new systems. And this paper analyzes the effectiveness of this new method through the example of Student authentication module.

The meaning of software sharing

With the popularization and development of computer applications, large to various industries, small to a company, departments have developed and applied a practical computer software. These software has greatly improved the efficiency of the company's enterprises and the level of modern management, it has become the company's business operation and management of the core. But since most companies use custom software in almost every department, it leads to a large number of useful but isolated and repetitive business logic blocks. If the design and development can avoid duplication of design, but the use of software sharing methods to achieve the same function of each module, it will greatly reduce the cost of software development, but also for the future system upgrades and integration to provide a good framework for the foundation. In addition, for existing business logic, you can reduce development costs by making small improvements to be shared by other applications.

Since the environment in which each application is developed is varied and technology is evolving endlessly, it is difficult to share an existing application to create a collection of features in the past. Fortunately, the advent of Web services technology provides a possibility for the realization of software sharing, the Web service of software functionality, the business logic that can be shared across the internet, and the creation of an open functional component system based on various Web services. Next, we will discuss how to use Web services technology to realize software sharing.

Realization of software sharing based on Web services technology

1. WEB Services Technology Introduction

WEB services can be viewed as APIs deployed on the Internet, which can be easily integrated and invoked by applications and even other Web services to form new application services. It has good encapsulation, loose coupling, highly integrated capability. There is no doubt that Web services technology will become the mainstream of the next generation of web technology, it is the realization of "software as a service" embodiment.

The Web services architecture is made up of service requesters, service agents, and service providers:


A Web service provider is the owner of a Web service that registers with the service agent to configure and publish the service, and patiently waits for other services and users to provide their own functionality; A Web service requester is a consumer of web functionality that uses a lookup operation to retrieve a service description from a service agent. It then binds to the service provider and invokes the Web service or interacts with it.
A Web service provider is the equivalent of a broker, which links a Web service requester to a suitable Web service provider, typically UDDI,UDDI provides a mechanism for the service requester to dynamically find Web services.

2. Implementation of software sharing based on Web services

In the process of software development, people often divide the software into different modules according to function, so as to facilitate the reorganization and reuse of modular functions and upgrade. Through the Web services technology to realize the software sharing, also need to first on the integration System by function partition module; Then, create a Web service to implement these functional modules, and to make the Web service accessible, you also need to publish a service description (deploy the Web service) so that other modules can find and invoke it. In this way, software features implemented as Web services can be shared by applications and even other Web services.

Service requesters, such as applications or other Web services, when they need to invoke a Web service, first retrieve the service description or query the service type required in the service registry. When you find the desired service, you can use the service description to bind to the service provider and invoke the appropriate service.

Microsoft's new flagship Visual Studio.NET is known as the preferred tool for developing Web services, and the use of Visual Studio.NET makes it easy to implement Web service creation and invocation. Below, a concrete example of software sharing based on Web services technology is given.



3, the application of software sharing examples: Student authentication module sharing implementation.

At present, there are many software systems in colleges and universities, such as: Course selection system, performance query system, network course system, library system, student financial system and so on. Because each system is independent of each other, each system has a student authentication module, there is a function of repetitive design; In addition, each system is independent of each other, there are students need to remember different systems password.

In view of the above situation and the highly developed campus network, we can use Web services to achieve the sharing of Student authentication module. The procedure for creating and invoking the Student authentication Web service with the C # language implementation using the Visual Studio.NET environment is described below.

1 Creation of Web services

The Student authentication module has 1 Web service components:

Public Boolean ValidUser (string userid,string Pwd)

Web service ValidUser is used to authenticate student identities. A basic Student Information table student is established in SQL Server database Studentsinfo, where fields UserID, pwd Save the student's user code and password respectively.

The following is a detailed description of the Web service creation process:

A to run the Visual Studio.NET development environment, create a new project Wsstudentlogin for the ASP.net Web service type.

b The concrete code implementation of the Web service.

Using System.Data.SqlClient;
Omit code ...
public class Service1:System.Web.Services.WebService
{
String Constr= "";
Connstr= "Database=studentsinfo; server=10.1.111.19; Uid=sa; pwd=; ";
Omit code ...
[WebMethod]
Public Boolean ValidUser (string userid,string Pwd)
{
Boolean Flag=false;
String Sqlstr= "";
Establish 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;
}
}

It should be noted that only the method described in [WebMethod] is a Web service that can be invoked remotely. Therefore, [WebMethod] in front of the method cannot be omitted.

To make a Web service available to others, you must deploy it to a Web server that is accessible to the clients you want to support. To deploy a Web service to a server other than the development server, you can add a Web Setup project or copy the required files to the destination server. For space limitations, this article does not discuss this in depth, assuming that the Web services for this example are deployed on the development server.

Once the Web service has been created and deployed, we can invoke the corresponding Web service on the client. The following describes how to locate and reference Web service features on the client.

2 the invocation of the Web service

The process of using a Web service is actually the process of implementing binding the Web service's consumer to the Web service implementation and calling its methods. To simplify the binding process. Visual Studio.NET provides a way to service proxy classes. A service proxy class generates a local class based on the Web service's description document (XXX.WSDL), in which the customer accesses the Web service using the information in the proxy class to implement the actual method invocation. Visual Studio.NET provides us with a simple way to achieve this process:

A Create a Web service access client program.

Web Services access clients can be different types of applications or other Web services. Here, we create a new "asp.net Web application" type of Project WebApplication2.

B, service Reference.

First, on the Project menu, click Add Web Reference. Next, because the Web service in this example is on the local computer, we click the Web service on the local computer link in the Browser pane. Then, click the Service1 link from the list provided to retrieve information about the Web service. Then, click Add Reference to add a Web reference for the target Web service. Visual Studio.NET will download the service description and build a proxy class that serves as an interface between the application and the Web service.

C, an example of the specific code that invokes the Web service in the client program.

private void Button1_Click (object sender, System.EventArgs e)
{//Create proxy class object
localhost. Service1 clientproxy=new localhost. Service1 ();
Try
{//Access Web service via code class object
if (Clientproxy.validuser (Txtuserid.text,txtpwd.text))
Label1.text= "OK";
Else
label1.text= "ERROR";
}
catch (E)
{throw e;}
Finally
{Clientproxy.dispose ();}
}
Other

WEB Services technology is the realization of software sharing, which provides a good technical basis for realizing system integration on the basis of existing information system. However, to make the software sharing based on the Web service technology is really practical. We also need to solve some of the following problems: First, security reliability, one is the connection reliability of Web service network transmission, the other is the reliability of Web services content, that is to ensure data integrity and confidentiality. The second is the control of the use of services, Web Services is "software as a service" embodiment, who is prohibited to use this service, who is allowed to use this service, how to use this service fees, etc., are the actual use of the problem to be solved. In addition, the hosting capacity of Web services, the deployment and discovery of Web services, and the failure handling of customer invocation Web services are also problems that need to be solved.

Summary

This paper proposes to realize software sharing from the aspect of software function sharing, discusses the use of Web services technology to realize remote software function sharing, and analyzes the effectiveness and the advantages of software function sharing through Student body verification module. The research of software function sharing has great significance to realize distributed computing, and it 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.