Delphi 6 Web Services preliminary assessment
This is a test report I have just arrived now (August 2001), which is now published, hoping to help everyone. Because D6 just issued, the Web Service has some problems. The current Update 1 for D6 has been released, mainly for Web Service, which is already compatible with the MS-related Web Service. The content mentioned in the article below has changed in Update1, hereby explanation!
On June 22, 2000, the entire IT industry is looking forward to a new era, because today's US Microsoft officially announced the .NET strategy, and determined that the annual investment costs of $ 4 billion a year. .NET's idea thoroughly converts the calculation mode from a single machine, client / server, and web website. Distributed computing. Although DCOM and CORBA are the popular distributed object models today, they all have only limited to local networks, it is difficult to break through the firewall restriction, so the entire Internet cannot be utilized as a computing resource system. The .NET is integrated in a particular application interface through a programming means of various resources distributed on the Internet through a technique called Web Services.
As the core concept of .NET, Web Services is currently hot technology, major manufacturers, such as Microsoft, IBM, Sun, etc., etc., etc., etc., etc., etc., etc., etc., is not invested in the leadership. Borland released the latest RAD tool Delphi 6.0 in June 2001, and supports Web Service as the largest selling point. Recently, I made a preliminary test and evaluation of Delphi6 to create a Web Services program.
1. Web Service Overview:
Web Services is equivalent to the API function that is often called in the past, and calls in object-oriented programming.
The interface, only the API exists on this unit, the interface usually exists within the local or local local area network, while the Web Services will be omnipotentially distributed across the Internet.
Web Services can truly implement cross-platform remote procedures to call RPC (Remote Process Call), no matter what the operating system is used, no matter how the hardware is used, no matter what language is used, it can handle its call request. Because Web Services is composed of SOAP (Simple Object Access Protocol as package protocol, HTTP (Hypertext Transfer Protocol) is composed of communication protocol, and is described by WSDL (Web Services Discription Language).
SOAP defines a mechanism for client calling server-side interface methods. Since SOAP is based on extended marker language XML (Extensible Markup Language) standard document, it can easily implement cross-platform, which uses XML to define a set of coding rules for network transfer call request information and response information.
HTTP, the communication protocol used by WWW (World Wide Web), because the firewall monitors each port, and the 80-port used by HTTP is used for Internet access, and usually the firewall does not limit this port communication, so it can generally pass the firewall, Connect the machine communication on the internet.
WSDL is used to describe the various information of the current Web Service so that information is obtained with the client through WSDL. Second, the evaluation test process:
The goal of the entire evaluation is to verify that Delphi 6 is supported by the establishment of Web Services engineering.
Services work efficiency and integration compatibility with other vendors Web Services.
★ Test environment:
CPU: PIII 550
Memory: 256MB
OS: Windows2000 Server SP2
Web Server: IIS 5.0 SP3
Development environment: Borland Delphi 6.0
Enterprise
Microsoft Visual Studio 7.0 Beta 2
Microsoft SOAP Toolkit 2.0
★ Basic testing process:
Web Services Call the return value through the interface method to obtain the call result, so the test program uses the interface method of different types of return values as the test direction, divided into the following four: string type return value, object type return value, object array type Return value and binary file return value.
1, test1 (string type return value method call):
First, use Delphi 6 to create a web services project, Delphi 6 automatically generates a unit through the wizard, including the respective controls required for Web Services communication: THTTTPSOAPDispatcher is used to respond to SOAP-based requests and transfer to other processing controls; HttpsoAppascalinvoker Used to receive SOAP messages from THTTPSOAPDispatcher and analyze call the appropriate interface method, and finally package the return result on the interface (eNCode); TWSDLHTMLPublish is used to publish the WSDL document describing this Web Service interface.
To provide an interface method for the Web Service service, you need to create an interface from Iinvokable inherited, and objects that implement this interface from TinVokable.
Below, we can add ways to this web service. In this first evaluation test, we need to add a string type as a method of return values, and we want to transfer a string of large data volume in order to use accurate test response efficiency. Therefore, a string of 1024 'Hello, The World!' Is created as the return value of the method.
The result of the call is shown in the figure:
(Figure 1)
The client's call has successfully obtained the string of the server side and displayed. After all, the server's encoding of the return value is also a text type, so there is not much time spent on the code, so the efficiency of the entire request can be satisfied.
Of course, it is because Web Services is SOAP, and the passing text is naturally "taking a good play", but in our practical application, the results needed usually not a string text, but other information, in order to continue
Certificate Web Services will bring us surprises, I have the next test.
2, TEST2 (Object Type Return Value Method Call):
In practical applications, we often encounter clients to return database query results from the server side, in which case the returned data may be a combination of various types of data, this test will tell us how to pass Web Services Pass complex type information.
The complex type data of the passed can be packaged through the object, which is easy to create in use, more important because Delphi "forced" we have to do this. In Delphi 6, if the interface returns value object, this object must be inherited from the Tremotable class, and the member variable accessible to the client can be published as an attribute. For tests, I created a class TXSPERSON from Tremotable, and announced six properties: ID, Name, AGE, GENDER, Content, EMAIL. So I can access the value of these six member variables of this class instance through the client. At the server side, I assigned these six values, respectively, and the class is used as the return value of the method. The client calls this method to get the TXSPERSON type object instance to access its attribute values.
The result of the call is shown in Figure 2:
(Figure II)
As can be seen from the above results, the efficiency of the transmission object is not transmitted high. First, all the server-side programs and client programs must manage a class, which naturally affects efficiency in the management overhead relative to the conveyance string.
From this test, we can deliver complex types. For the vast majority of practical applications, each delivery is not enough, we may need a large number of database records. In Web Services, you can implement the use of dynamic arrays, as follows.
3, TEST3 (Object Array Type Return Value Method Call):
When a large database record in the server side needs to be passed to the client, each record is saved as an object instance, and all records are saved with an object array and passed to the client as the return value to the client. In this test, I used the way to combine with the database to facilitate the more real simulation of actual applications. Database I use Access2000, connect access through ADO (Microsoft ActiveX Data Objects), and create a result of a dynamic array saved the query to return to the client as the return value.
The result of the call is shown in Figure 3:
(Figure 3)
It can be seen that the call is still very smooth, and the client has obtained the desired information record. However, relative to the transmission of a record, the efficiency is again reduced. It should be said because the cause of the dynamic array leads to a decrease in efficiency. The dynamic array is a feature of Delphi. In C / C , there is no dynamic array, so the memory of the C / C in the C / C is allocated during compilation. Dynamic arrays are introduced in Delphi, which can only distribute memory during operation, resulting in overhead caused by dynamic array management.
In practical applications, sometimes we need to pass files, such as the picture inside the database, what should I achieve through Web Services? As a simple solution, we once again help to dynamic arrays.
4, TEST4 (binary return value method call):
In the last return value type test, in order to test the transmission capability of the web service, I passed a JPEG picture through the method results. To enable the client to receive pictures of the server side, you must use a standard return value type to organize the contents of the image, and the dynamic array TByTednyArray is used in the test as the return type.
The server side reads the contents of the image file through TFileStream, and copies into the TBYTEDnyArray array, and the client receives the array of TBYTEDnyArray types to write back to the file using TMEMORYSTREAM to complete the file transfer process. The result of the call is shown in Figure 4:
(Figure 4)
The function is indeed, but the result of the test is surprising, although it is also guil that the "huge" dynamic array will have a relatively large impact on efficiency, and the facts have also proven that this way implements files. The method of transmission is not feasible.
There is no doubt that such a low efficiency is due to the overhead of the dynamic array. For 15KB of pictures, the dynamic array will generate an element for each byte of its, and the system's memory management is so "stretched" .
Although this method is used to pass our "failed", it is not an explanation of the way without high efficiency. As a binary file, if you want to pass the return result as a web service, you must store the binary file in SOAP information, soap is a text file, so for binary files to transfer online, it can be used The mature agreement is the most commonly used Mime (MultiPurpose Internet Mail Extension Protocol). After encoding the picture through the base64 encoding or other means, it is passed to the client, and the efficiency will be improved in the decoding of Base64. But because Delphi 6 provides Base64 coding decoding, I gave me a test of this method because some imperfect reasons.
★ Test overall impression:
In the entire test, the Web Services created by Delphi 6 has the following Impansions:
1. When the client application is connected to the server-side Web Service, the first call is slow, and the future call is significantly accelerated.
Figure 5 shows the transfer rate of the first and second time to call each interface (the number of kilobytes per second is transmitted).
It can be seen that the first method call is very time consuming, it may reach 8 times the second call, so it can be determined that when the interface is called, a large number of operating events are consumed above the connection. Once the connection is established, the future call speed will be greatly accelerated.
(Figure 5)
From Figure 5, it is also possible to see the efficiency of various returning type tests.
2. When the first method call consumption is thrown, some methods are unstable each time the test data transmission rate is unstable. For example, in Test1 and Test2, the substantially rate is 850kb / s or 1134kb / s, and the transmission rate of TEST3 is very wide, from 401kb / s to 530kb / s, and Test4 test is too small because the rate is too small. It may lead to a relatively large error, which is not considered here.
Test1, Test2 relative test is relatively stable because the server side returns the required value directly, and the rate change is only for the transfer process. Data must be read from the database in Test3, and create a dynamic array to deliver information, so there is more rate influencing factors, resulting in a relatively large change in transmission rate.
★ Web Services compatibility problem test:
It is because of the hotness of Web Services, leading to all major manufacturers to smell, and launch their own concepts and build their own solutions. For example, Sun is launched by ONE (Open Net Environment) to fight Microsoft, Oracle's concept with Microsoft with the concept of Dynamic Web Service. SOAP specifications are constantly developing, from 0.9, 1.0 to now 1.1. However, software for providing SOAP functions on the market is not necessarily compliant with the latest SOAP specifications, even if they support the same SOAP version specifications, there may be some differences in how to implement. However, it may be because this subtle difference may result in the trouble of software developers, let alone Web Services is a SOAP-based communication technology. Therefore, if different SOAP software interfaces are different for SOAP specifications, it will cause client applications to communicate with Web Service, or unable to use each other between Web Service and Web Service. This will lose the essence of SOAP and Web Services technology.
The following test uses the currently most popular platform for compatibility testing, Microsoft Visual Studio 7 Beta 2, and the Delphi 6 Enterprise just released.
In the previous test, I use Delphi 6 to create web services and use the Delphi 6 development client to connect, the whole process is perfect. However, now, our test is currently the most popular development tool "peaceful coexistence"?
First, I am under the VS7 environment, using C # created a web service, providing a method addxy (int x, int y); however, when I call in Delphi, it is very disappointed, and there is a call as shown in Figure 6. error:
(Figure 6)
It seems that VS7 and Delphi6 can't cooperate well. When using the tracking tool TRACE UTILITY with MST2 (Microsoft SOAP Toolkit 2.0) to intercept the HTTP information, check the passing SOAP information. Some of the Web Services developed by the Web Services developed by VS7 developed Web Services have some different SOAPs. It is because these formats are different, resulting in failures of communication between them.
Moreover, not only the SOAP format is not quite, even the WSDL format is very large, so that Delphi 6 imports the method issued by our VS7, the generated interface declares as follows: Procedure Addxy (VAR Parameters: addxy); STDCALL; thus generated a very good thing to "embarrass" itself, this is a procedure instead of function, calling this method does not return value, that is, the result of the method call, although the generated interface method The parameter parameters is the ADDXY class and is a variety of a var type, unfortunately, unfortunately, the result of the client needs is not included in the Addxy class. Delphi declares a result of a result of ADDXYRESPONSE for this method, but we cannot get this object instance by calling methods. By further analyzing the interface WSDL of the interface, it is found that there is some bug that the interpretation of Delphi 6 on the WSDL file has led to an error in the generation interface declaration.
In general, there is still a big difference between the Web Services program between Microsoft and Borland. But this is not to say that we cannot call the Web Services method created by VS7 under Delphi. We can also access the COM interface provided by MST2. Through my test, this method has no problem, it is possible to call VS7's Web Services, after all, MST2 and VS7 Beta2 are Microsoft products. Of course, it is not compatible between them, making us very hurt, as the current two main development environments, can't let us experience the Web Services cross-platform, cross-language superiority, is really disappointed.
After all, SOAP and Web Services standards and technology are still in fast development, so the details of each realization may be slightly different. Maybe after the SOAP function is mature, there will be no more annoying details. According to information, Delphi 6 Web Services is a smooth integration to many Web Services implemented by Java or Java client applications. It seems that Borland Delphi 6 Web Services is still biased towards IBM camp!
★ Create web services:
1, IIS 5 related settings:
Because the Web Services created by Delphi 6 is an ISAPI program, you must use IIS as its server. In actual development and applications, you should pay attention to the problem of cache settings for ISAPIs.
Start Internet Service Manager, select "Properties" of the Web site, and select the "Main Directory -> Configuration" of the pop-up dialog box will pop up the dialog shown in Figure Seven.
(Figure 7)
During the Web Service server-side programming, since the "Cache ISAPI Application" cannot be used, the "Cache ISAPI Application" cannot be used, otherwise, once the program is run, the server program is always in use, recompile The new program cannot be overwritten.
Once the server-side program is completed, it is best to select "Cache ISAPI Application" because it will be greatly improved in the future execution of the ISAPI application, and the efficiency will be greatly improved in the future execution, according to the test, at least more than double Improve the magnitude.
2, Delphi 6 Create a debugging method for Web Services project:
As a ISAPI application running under IIS, Web Services created by Delphi is a DLL dynamic library, so debugging methods and general applications are not only the same:
In the wizard of creating a Web Services program, you should select the Web App Debugger Excutable program, which is created will be an executable program. Then use the "Web App Debugger" debugging tool comes with the Delphi 6 as the web sever, and set the corresponding port, at this time, you can debug the server program below the Delphi IDE.
After the program is running normally, it is necessary to publish as an ISAPI, just re-establish a web Services ISAPI program, and add all the relevant files under the debugger to the new project.
Third, summary:
In the above test, it has been proved that Web Services can deliver a variety of information, because Delphi has encapsulated the underlying class to transmit complex type information, so developing Web Services is relatively simple with Delphi6. The current main problem is that the integration between Microsoft, Delphi 6 has an error in the interpretation of Microsoft WSDL, and some other mutual differences, causing them to call each other. Although MST2 can be used in Delphi 6, this is equivalent to abandoning the Web Services support of Delphi 6 itself. During the entire test, I mainly pay attention to the use of Web Services practicality, though Web Services
However, it is not particularly ideal in terms of transmission efficiency, but after all, Microsoft's .NET strategy is a concept of advanced concepts, and its truly mature must rely on the popularity of broadband networks to let users experience web. The superiority of Services.
At present, the research on Web Services has just started, and major forums have recently launched the relevant discussion versions, and relatively complete. As the core concept of future software technology, the hotness of Web Services will increase.
As software vendors participate in the enthusiasm of Web Services research and development, it is prompted the rapid development of Web Services, as well as the identification of relevant protocols. With the increasingly mature and self-improvement of the external environment, Web Services is inevitably swept throughout the industry as a new software development concept. As Microsoft said: "Empower People, Any Place and ON ANY Device." (Advanced software makes people, anywhere, with any device to get powerful energy)
Reference:
"Soap War and Peace" ----- Li Wei
".NET: Interpretation of Microsoft Internet New Strategy" ----- Mao glow Chen Zhihong
"Borland Delphi 6 Help"
"Borland Delphi 6 for Windows Developer's Guide"
......