Web Services study notes (1)

zhaozj2021-02-08  219

Web Services study notes (1)

Author: Cai Huanlin Date: Apr-3-2002

Summary: Briefly describe the concept of Web Services, the origin, mode of operation and application, and composes the Web Services user-ended steps in Delphi 6 and VisualStudio.net.

What is web services?

Platform neutral network service

Web Services is a platform-neutral network service. The application can specify a service provided by URL to access any a computer on the Internet, regardless of the type of computer of the other party, and both parties follow the standard agreement. Can communicate.

Decentralized application of cornerstone (Building blocks)

Based on the characteristics of its platform, software developers can publish design WEB Services on the Internet for other applications, other developers can reuse these existing services to construct a decentralized application, without spending time Software components of the same function are redesigned.

Web Services makes the concept of "software,", and also means that the scope covered by the decentralized architecture will be broader.

Why have Web Services?

The front has been married, Web Services will improve the repetitive use rate of soft components based on its platform, and the Internet does not expensive, which is one of its benefits, in addition to this, we can also Demand and two angles of technical planes are discussed why Web Services is required.

Business needs

Early enterprises Data exchange between enterprises is reached in EDI (Electronic Data Interchange, electronic data exchange), but due to more expensive exclusive systems, use specific agreements and data formats, so maintaining high maintenance costs, no expansion easy. With the rise of the Internet, highly open architecture, agreements, and information formats are popular, such as TCP / IP, HTML, XML ...., etc., and contribute to customers (B2C) The company's e-commerce boom on the enterprise (B2B). In terms of B2B, it has gradually formed a business model of EmarketPlace. This model provides a trading place (website) by third parties, so that the merchants will trade here, and the information input is still dominated by manual operation. At present, the competition in various industries is said to be the key to the winning and negative. If you can change the manual input information to the computer, you can significantly reduce the time between enterprises and information exchange, and then enhance the competitiveness of the company. With the reaction speed. The WEB Services that sets the public standards is just in line with this demand.

From this view, you can also see another feature of Web Services: transition to the interaction between the previous user and the application into the interaction between the application and the application.

Existing technology

If you need web services, you can see why the existing decentralized architecture is insufficient. At present, most of the decentralized applications are available in a remote program call (RPC) to access another computer, such as Microsoft Distributed Component Object Model (DCOM), Sun's Remote Method Invocation (RMI), OMG's Common Object Request Broker Architecture (CORBA), etc. These use RPC-based decentralized architectures provide the advantages of developers familiar with program (function calls) and location transparetric (Location Transparency). But it has the following disadvantages: closely coupled. The user-end and the servo program must specify the detailed call mode, and the user has to know how to access the details of these services in advance (such as any parameter and its type thereof), the server is slightly changed. The client will not be executed. Only synchronous execution (Synchronous Calls). When the user calls a program of the server, you must wait for the program to continue other actions, and the user can do only. Although it can be solved using multi-execution techniques, it has increased the complexity of the program, and the program is more difficult to write.

When the application needs to perform operation in an asynchronous manner, another so-called message-oriented architecture, for example: Microsoft's MSMQ, IBM MQSeries, etc. Is there a program call mode of RPC, this architecture uses a mechanism for non-synchronous messaging, and the user can continue to perform other work after sending out, the message guarantee will be delivered to the destination, as for the maximum delivery, this is the largest Features, and its disadvantage is:

The message received first processed (伫 伫), which is unable to provide the order of execution of a particular workflow. The programming designer must handle the packaging, interpretation and verification of the message package, is a non-light burden. The solutions provided by each manufacturer are incompatible with each other.

Whether it is an RPC or a message-oriented architecture, they have a common disadvantage, which is to tie together with a specific job environment or software, and various products use different transport protocols or data formats such that they cannot communicate with each other. In addition, DCOM, RMI, CORBA and other binary agreements are usually blocked outside, so that the outside world cannot directly access the information services within the enterprise. To make them can pass through the firewall, the network management must cave the hole on the wall. Such potential will cause problems for network security, which is also a more headache in the existing decentralized architecture.

In order to solve these problems, Web Services came into being. It has the following features:

Loosely-Coupled decentralized architecture. Platform neutral, unrelated to the actual (development tool, program language). Stateless. Provide synchronous program calls with non-synchronous program. It is easy to cross the firewall.

But not to say that Web Services can completely replace traditional decentralized techniques, can only say that there is a timing that they apply, when assessing which technology to use to develop applications, in addition to understanding the advantages and disadvantages of technology itself, It does not understand the needs of the application and the environment of the environment, there is no such thing as cutting-edge technology. How is the web services working?

Web Services must be able to work, the first thing to solve is:

How to use the remote program call through the Internet, and don't know the other party's work environment and application type? How do users know how to use a web service? Or, how do you know the interface of the service (which method calls are provided)? When the application needs a certain function, how do you know the web services that already provide such features on the Internet? Where can I find these web services?

The answer to the first question is a standard message format to be delivered between the platforms. The second question requires a file that describes Web Services, and the client can understand how to use it through this file. The third question can have a similar directory service, providing an existing Web Services for an existing query.

Web Services has three important elements to solve the above problems, they are:

SOAP - Format of the message WSDL - Description Service Soap Discovery - What services are found?

It is also known that they are Web Services three swordsmen, and the following will further explain.

SOAP

The previous mention of the Web Services is the platform, not only refers to the homework system, even the brand of the website, the type of application is not particularly limited. For example, the user-end work environment is Windows 2000 IIS, and performs Web Services The work environment is Linux Apache. To meet these conditions, you must have a standard agreement, this standard agreement is Simple Object Access Protocol (SOAP).

SOAP is an object access agreement schema above HTTP, which means that the message is transmitted through http, and the content of the message is described in XML format. When the user ends need to call a remote object, the requirements can be encapsulated into a SOAP call to pass to the remote web services, and when Web Services receives the user's request to execute the specified method, and execute After passing, the result is followed. Therefore, it is also possible that SOAP is the RPC above the Internet.

Compared to the traditional RPC, SOAP is not only a disclosure standard supported by the industry, but also has the advantages of easy to penetrate the firewall, so that the remote program call is smoothly across different domains. SOAP can smoothly penetrate the firewall, because its equipped text message is transmitted through the HTTP agreement, and most of the company's firewall opens HTTP's 80 埠.

WSDL

When you find a Web Service on the Internet, how do you know how to use it? What services do it provide? What is the way to call? What parameters to pass? The answer to these issues is WSDL (Web Service Description Language).

WSDL is a file written in XML. The attached name is .WSDL, its main purpose is "Description Web Services", which is to let the client know how to use Web Services. WSDL's file content also has a common standard to integrate with various user-end applications, which is combined with IBM and Microsoft. If you understand COM, WSDL's role is equivalent to COM's IDL (Interface Difounding Language) or Type Library.

Web Service Discovery (also known as disco)

WSDL is useful in the case where you have determined to use a web service and know its URL, don't know what to do with Web Services you need? For example, your application now adds a feature, allows the user to enter a specific keyword to find the download URL for the relevant MP3 file, this time you have to find this kind of web services?

Disco use here, just like a phone book and a search engine site, provide information classification and service, allowing you to easily find the web services you need.

The principle of operation is that when the developer completes a web service design, you can log in to a concentrated place, others can find the needs you need to concentrate on this centralized query. This login - the mechanism of the query is achieved by UDDI (Universal Description, Discovery and Integration).

Architecture of Web Services

Combining XML, SOAP, WSDL, UDDI These core elements can form a web services architecture, including three main characters in the architecture, which are web services, consumer, and In the Broker between the two, refer to the figure below:

Its operational process is as follows:

Service provider develops web services. The service provider deposes the Web Services to the server and logs in to the service intermediaries to the UDDI registration database. Services of consumers search for the required services in the UDDI registration database. The service can be used after obtaining Web Services.

Possible challenge

In the face of a new technology, in understanding it and learn how to apply this technology, it must also pay attention to the problem that may be accompanied by the technology, so as not to use the technology wrong place or discovers the wrong mistake. . So this summary lists some challenges that may encounter when applying Web Services, which is taken from Graham Glass, "The Web Services (R) Evolution, Part 1.

reliability

If the server that is originally provided, the server should be changed? Is it possible to temporarily replace the Web Services provided by other vendors? Is this alternative to the function and how the use of the original Web Services is exactly the same?

safety

When passing sensitive information on the Internet, you need to encrypt the data, and HTTP can provide basic security protection, but it is not enough to verify and authorize some to verify the personal identity. What extent Is it safe? Do you need to pass and verify the identity of the user in each method call? Where is the efficiency and security balance? Transaction processing

Previously decentralized applications use two-section delivery to complete a decentralized transaction, this way does not have any problems in the environment in which short-term transactions in an enterprise network, but if you get the Internet In the open environment of the road, it is difficult to obey because a transaction is launched, maybe after several days of trading is completed, whether the operation of the transaction is going to wait until all the work participating in the transaction is successfully confirmed to complete the entire transaction? It is actually impossible to do this. Therefore, Web Services still needs to be effort in the processing of decentralized transactions. Currently Microsoft proposes a program (XLANG) of compensation transactions, while W3C has not yet set relevant standards for this issue.

Business model

How do you charge your web services? How much is charged for charge for charge? How do you prevent users tell other people to share your web services?

Defect

Since each user end executives may be different, how to ensure that your Web Services can apply to the environment of various clients, when the user returns the wrong message to you, are you? Solve the problem within a limited time? Need analog user job environment?

Cow knife trial

After understanding some basic concepts, let's try to practice a simple example program. Introduce the writing steps of the decentralized application, usually create the program of the servo terminal, and then establish the user's terms because the specific functions required by the user are often unused, but must be written by themselves. Fortunately, there are many ready-made Web Services, we can learn how to write difficulty users, and learn how to write Web Services after using it.

First select the web service, http://www.xmethods.com has many ready-made, I plan to use a Web Service called Email Address Verifier to do demonstration, it provides verification MSN, Hotmail, and Yahoo, etc. Free email mailbox is valid. This web service is developed in VisualStudio.net, which I will describe the development of the Web Service user with Delphi 6 and VisualStudio.net 7 English. You can see how the two tools are written. .

Write user terms in Delphi 6

Create a new application: File | New | Applicat, then archive first. Through WSDL Importer to transfer the specified Web Service interface to Delphi: File | New | Other ..., select the WSDL Importer of the WebServices page clip, then press the OK. In the next WSDL, enter the WSDL of the Email Address Verifier in the WSDL: http://ws.cdyne.com/emailveriffy/ev.asmx? WSDL, which will generate a new unit Ev.PAS after completion. The EVSoAP interface that inherits from Iinvokable is the interface we want to call remote objects. The following components put one to FORM1: THTTPRIO, TEDIT, TBUTTON, TMEMO. Where TMEMO is used to display the results of the authentication Email mailbox. Then press Alt F11, this unit. Set the properties of HTTPRIO1, as follows: Object httprio1: trttprio

WSDLLOCATION = 'http://ws.cdyne.com/emailverify/ev.asmx?wsdl'

Service = 'ev'

Port = 'evSoap'

Converter.Options = [SOSENDMULTIREFOBJ, SOTRYALLSCHEMA, SorootRefNodestobody]

END NOTE: Since Email Address Verifier is a .NET application, use the WSDLLOCATION property, and the Web Services developed in Delphi can use the URL properties. Write the onclick event of Button1:

Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);

VAR

INTFEV: EVSOAP;

Ri: returnindicator;

Begin

Screen.cursor: = CRHOURGLASS;

Application.ProcessMESSAGES;

Try

INTFEV: = httprio1 as evSoap;

Ri: = intFev.verifyemail (edit1.text);

Memo1.clear;

Memo1.Lines.Add ('responsetext:' ri.responsetext);

Memo1.Lines.Add ('responsecode:' INTOSTR (RI.RESPonsecode);

Finally

INTFEV: = NIL;

Screen.cursor: = CRDEFAULT;

END;

End; compile and execute. Enter a free Email mailbox for your own MSN or Yahoo in Edit1, then press Button1 to see the verification results shown in Memo1. If the verification result shown in Memo1 is "Verified Email Address" or "Mail Server Accepted Email", it means that the email mailbox you entered is effective. At this time, you can open an email software to see if there should be a seal. The notification letter sent by www.email-tester.com, which is really providing the verification service behind it. If you enter someone else's mail mailbox in your previous step, you will have someone else. Executive results Refer to the following image:

Write user terms in VisualStudio.net

I wrote in C #, the steps are as follows:

Point-selected master menu file | New | Project, in the "New Project" dialog window, "Project Type", "Visual C # Projects", "Templates" Select Windows Application, "Name" Enter "EmailverIfyClient", then Press the OK button. Refer to the following picture: Project | Add Web Reference in the point of the master menu, in the window, the field address wants to enter the web service's URL, where we directly enter the WSDL address of Email Address Verifier: http: // WS. CDYNE.COM/emailverify/ev.asmx?wsdl, then press ENTER. If you find this web service, you will be displayed in the lower panel. At this point, you can join the web reference, which means to generate this web service's Proxy category. The operation screen is shown below: Produced Proxy Categories The name is "EV", you can find and call this category code in the Class View window. Put two TextBox on Form1, a button. Add the following code in Form1.cs:

Using emailverifyclient.com.cdyne.ws; written program code in the Click event of Button1, as follows:

Private void Button1_Click (Object Sender, System.Eventargs E)

{

EV OEV;

Returnindicator RI;

OEV = New EV ();

Ri = Oev.Verifyemail (TextBox1.text);

TextBox2.text = ri.responsetext;

} Compile and execute, first enter the MSN or Yahoo email mailbox in TextBox1, then press Button1, and the verification result is displayed in TextBox2. Execution Screen Refer to the following image:

The program of the above two development tools is actually small. It is worth noting that both can automatically generate the Web Service's Proxy category, and the process designer can access the Web Service through this Proxy category while writing the User-end program. The services provided by components.

Panel

EvClient_d6.zip (for delphi 6) EvClient_vs.zip (for vs.net) Conclusion

After the giving of the INTERNET, after the global economy, the software industry will gradually feel the pressure of globalization, but have to join the world's pulsation. The emergence of Web Services provides a way of communication between applications, a wide range (all over the world), supported platforms, maybe it can create another emerging software service industry, and will have all around the world. A wide variety of software services, the selection of jewels, and the software developers need no longer have to be limited to a development tool or program language. Does Web Services provide enough conditions to reach this vision? And let us wait and see.

This time, in addition to introducing some of the basic concepts of Web Services, it is also showing how to develop Web Services user terms in Delphi 6 and VisualStudio.NET in Delphi 6 and VisualStudio.NET. The next time you have the opportunity to further introduce relevant issues related to Web Services program.

Reference

Myths and misunderstandings surrounding soap by frank cohen. Website: http://www 106.ibm.com/developerWorks/webservices/library/ws-spmyths.html The Web Services (R) Evolution, Part 1 by Graham Glass. Website: http://www-106.ibm.com/developerworks/webservices/library/ws-peer1.html Introducing .Net by Conard, DENGLER, FRANCIS, GLYNN, HARVEY, HOLLIS, RAMACHAN, SCHENKEN, SHORT, ULLMAN. WROX Press 2000.

转载请注明原文地址:https://www.9cbs.com/read-3113.html

New Post(0)