★ 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 obtains the invocation result by calling the return value of the interface method call, so the test program is divided into the following four types: String type return value, object type return value, object array type return value, and binary return value, by calling the interface method of different type return values as the test direction.
1, TEST1 (String type return value method call):
First using Delphi 6 to create a Web services Project, Delphi 6 automatically generates a unit from the wizard, which includes the individual controls required for Web Services communications: Thttpsoapdispatcher is used to respond to SOAP based requests. and handing it over to other processing controls; Httpsoappascalinvoker is used to receive SOAP messages from the Thttpsoapdispatcher, to parse and invoke the appropriate interface method, and finally to encapsulate the result of the interface call return (Encode) Twsdlhtmlpublish is used to advertise the WSDL document that describes this Web service interface.
To provide an interface method for Web service services, you need to establish an interface that inherits from Iinvokable, as well as objects that implement this interface from Tinvokable.
Next, we can add a method for this Web service. In this first evaluation test, we need to add a string type as the return value method, and in order to be as accurate as possible to test the response efficiency, we want to be able to transfer the larger data volume of the string. So created a 1024 ' Hello, the world! ' The combined string is used as the return value of the method.
The result of the call is as shown in Figure one:
(Figure I)
The client's call, successfully obtained the server-side string and displayed it. After all, the server for the return value of the encoding is also a text type, so the time to say code is not much, so the overall efficiency of the request can be satisfactory.
Of course, because Web services is soap based, passing text is naturally "a specialty", but in our practical applications, the results are usually not string literals, but other information, in order to continue
Proof that Web services will be a surprise to us, I have the next test.
2, TEST2 (object type return value method call):
In practical applications, we often encounter the client needs to return the database query results from the server, in which case, the returned data may be a combination of various types of data, this test will tell us how to pass the complex type of data information through Web services.
The delivery of complex types of data information can be encapsulated through the object, easy to create in the use of management, and more importantly, because Delphi "forced" we have to do so. In Delphi 6, if the interface returns a value of an object, the object must be inherited from the Tremotable class, and the member variables accessible to the client must be advertised as attributes.
For testing, I created a class Txsperson inherited from Tremotable, and published six attributes: ID, Name, age, Gender, Content, Email. So I can access the values of these six member variables of this class instance through a method on the client. On the server side, I assigned the six values, and the class as the return value of the method. This method is called by the client to get an object instance of the Txsperson type, thereby accessing its property values.
The result of the call is as shown in Figure two:
(Figure II)
From the results above, it can be seen that the efficiency of the transfer object is no higher than the transmission string. First of all, both the server-side program and the client program must manage a class, which has a natural impact on efficiency relative to the management overhead of passing strings.
From this test, we can pass complex types of data, for the vast majority of practical applications, each delivery is not enough than the data, we may need a large number of database record delivery. In Web services, you can do this by using a dynamic array, just as the next test.
3, TEST3 (object array type return value method call):
When a large database record on the server side needs to be passed to the client, each record is saved as an object instance, all records are saved with an array of objects, and the object array is passed to the client as the return value. In this test, I used a combination of the database to test, in order to more realistic simulation of the actual application. Database I used Access2000, connected through ADO (Microsoft ActiveX Data Objects), and created a dynamic array to hold the results of each field of the query, returning to the client as the return value.
The result of the call is as shown in Figure three:
(Figure III)
As can be seen, the call is still very smooth and the client gets the desired data record. But efficiency is again reduced relative to the transmission of a record. It should be said that because of the dynamic array caused by the reduction of efficiency, dynamic array is a feature of Delphi, in C + +, there is no dynamic array, so the memory of the arrays in C/s + + is allocated during compilation. In Delphi, dynamic array is introduced, which makes it possible to allocate memory dynamically during runtime, which results in the overhead and efficiency of dynamic array management.
In practical applications, there are times when we need to deliver files, such as the pictures in the database, and how the Web services should be implemented. As a simple solution, we turn to dynamic arrays once again.
4, TEST4 (binary file return value method call):
In the last return value type test, to test the ability of Web services to transfer files, I passed a JPEG picture through the method results. To enable clients to receive server-side pictures, a standard return value type must be used to organize the contents of the picture, and dynamic array tbytednyarray is used as the return type in the test.
The server side reads out the contents of the picture file through TFileStream, and copies it to the Tbytednyarray array, the client receives the Tbytednyarray type of array and uses Tmemorystream to write back to the file, thus completes the file transmission process.
The result of the call is as shown in Figure four:
(Figure IV)
function is true, but the results of the test is surprising, although it is also suspected that the use of such a "huge" dynamic array will have a greater impact on efficiency, the fact is indeed also proved that this way to achieve the file transfer method is not feasible.
There is no doubt that such low efficiency is precisely because of the cost of dynamic arrays, for 15KB images, the dynamic array will generate an element for each of its bytes, the system's memory management will eventually appear so "stretched."
Although we "failed" to pass the file in this way, it was not a way of stating that there was no efficient delivery of documents. As a binary file, if the return result of a Web services is to be passed on the network, the binary file must be stored in the SOAP message, and SOAP is a text file, so it is entirely possible to use a mature protocol for binary files to be transmitted online as text files. The most common use is MIME (multipurpose Internet Mail Extension protocol). BASE64 encoding or other ways to encode the picture, after passing to the client, in the BASE64 decoding, the efficiency will be increased dozens of times times. But because Delphi 6 provides BASE64 encoding decoding, I give up the test for this method because of some imperfect reasons.
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.