Delph6 Generates Web Service and Its Time Efficiency

zhaozj2021-02-17  56

Web Service Test Report (Delphi)

Description: Operating a Web Service using Delphi is not complicated, creating a Web Service service and generating client calls is not difficult, there are several current component wizards in Delphi6, we can use it to build The interface method we need is just a bit of hard work, etc. After the shelf is getting up, it is easy to add a new method, I will combine an example to describe my creation process, and simple Explain that its execution efficiency is tested, and finally with Sun Yipu, it is more favorable (all aspects).

Test Environment: Web Service (hereinafter referred to as WS) is placed on this unit and takes IIS's web services. The client is also in this unit, both ends are written in Delphi6.

Time Efficiency: Time-consuming main fees in two aspects, one is the positioning of WS; its second is the connection of the database and the operation of the database (mainly consuming, I think it is almost negligible).

Perform an operation (such as: SELECT or INSERT SQL operation) is about half a minute, mainly the first time, if you do a few actions, then how long is it. So the biggest time is time consuming in the positioning network of WS.

On the connection of the database, I did two instances. One is to do related operations with an ODBC connection. The other is to use the ADO connection to do it. These two instances give me a feeling of almost time, there is no difference, Waiting for you to see it again.

Programming is difficult to write: In addition to those new components, the rest are all in Delphi5, the difficulty is not very big, and it is easier to get started. If there is a pattern, it can be set. I spent the first WS, I spent a day, mainly in the domestic site, using C # speaking, it is difficult to find a ready-made example with Delphi, I am combined with "programmer" magazine and Written by two abroad sites.

Below I will describe this TEST's idea process and some key technologies, give you a reference, I hope to throw bricks, huh, huh!

First, the server is implemented

1. New An Application

2. Select SOAP Server Application in New Items Page Select SOAP Server Application, which will automatically generate a web module, with three components: a TTPSOAPDISPATCHER component, an HTTPSOAPSCALINVOKER component, and a WSDLHTMLPublish component, as shown below:

The first component responds to the SOAP requests to send them to our web module. The second component translates the coming SOAP request to the calling process of our Pascal object method. The third module produces us based on us Call the interface of WSDL so that the outside world can know how to use our web services, these we can do it, because this is automatically generated, if you don't want to study the Mechanism of WS, these can be thrown one side, because they The function has all been generated, don't worry.

3. Then generate two more important files to describe which services are available outside the Test WS, according to I explore, these two files can only handle, they are also WS in Delphi shelves. Specifically how to write to my source code, there is in the shared directory of Wang Jianbai.

4. Regenerated into a data module, it is used to deal with the database, with TDatabase, TQuery (two of the Slesql placed in the feedback result, one is an execsql without feedback results), this DM is implemented in the interface implementation in step three Up. 5. After these are done, build an exe file, a web service is completely generated, pretty cool, huh !, then we can use http: // localhost / service / test / item / wsdl / ity, you can Seeing this WS's WSDL description, everything is ready, just waiting to call.

Second, the client is implemented

Note: Client applications that call Web Service are easier to use Delphi6, because it provides the ThttPrio components in the Webservices component group, as long as we set it WSDL to call WS, then THTTPRIO components can Automatically handle all the details of all WS.

step:

1. NEW a project Application

2. Select Web Service IMPORTER in the new items page, enter http: // localhost / service / test / item / wsdl / itest in the prompt box, which is WSDL (filename or url), the system will automatically generate a file, come Describe our WS, this we can also do it, open it, there is a function we define.

3. NEW A FORM, in the THTTPRIO component, set its attribute wsdllocation, the same string, choose its port and service properties, the preparatory work we should do is done

4. A Button came over and wrote the method you want to call. Ok, all over!

There are a few points of attention:

1. In the WS method implementation file, you want to create a data module. In my program, use createDM private functions to complete, and finally FreedM, don't do it in Project, use Application.creatform (TDM, DM) in Project, do not worry WS Will be wrong.

2. In the IIS virtual directory, be sure to select the right to execute the CGI, or not.

3. When New SOAP Server Application, it is best not to select WS in the form of a DLL. If you don't compile, you will always restart, otherwise it is not compiled.

Also there is a problem:

1. When you call WS, you can't track it. I don't know if there is any good way.

2

. apart from

DM

In addition, if there is any other way, I don't know if there is any other way, because I want to build a database operation or business logic.

WS

The above layer, let it run first, stay in memory, so later

WS

When you are toned, you don't have to connect to the database because it has been built, this may greatly improve the time efficiency, these problems, I want to slowly think about it later!

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

New Post(0)