Develop Web Services database programs with Delphi

zhaozj2021-02-16  56

Step 1: Write the application of the server

First select "File | New | Other ..." in Delphi IDE, then select the SOAP Server Application icon in the WebServices page, as shown below:

Then select Web App Debugger Executable in the New Soap Server Application dialog, as shown below: After clicking the OK button, Delphi will automatically generate a webmodule, which contains three WebServices controls in this module, as shown below: then Then select the SOAP Server Data Module icon in the WebServices page, OK, Delphi pops up the SOAP Data Module Wizard dialog, as shown below: Enter the class name in Class Name: D6DBDataModule1. After clicking OK, Delphi will automatically generate a SOAP data. Module, add TDatabase, TQuery, TDataSetProvider, three controls in this module, as shown below: Set the properties of each control, basically the same as the previous Delphi database application, where tdatasetProvider is a DataAccess control, provided Remote call support.

Compile the application to make it registered. Complete the server-side application design.

Step 2: Write the client's application

Add a new application project, add TDBNAVIGATOR, TDBGRID controls in the Form form, as shown below: Add a data module, add TsaopConnection, TclientDataSet, and TDataSource controls, as shown below: where the TSAOPConnection control is Utilize the SOAP protocol with the remote server-side interface. The property settings are shown in the following figure, the URL of TsaopConnection is formatted: http: // Webserver address / Webservice application name / SOAP / SOAPSERVERDATAMODULE name

Then set the properties of the TClientDataSet control, set the RemoteServer's properties to the name of the TsaopConnection control, click ProviderName. Next, add the following code in the unit where the form is located: Unit Unit4; Interface

Uses

Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Extctrls, Dbctrls, Grids, DBGRIDS; TYPE

TFORM4 = Class (TFORM) DBGRID1: TDBGRID; DBNAVIGATOR1: TDBNAVIGATOR; Private

{Private Declarations} PUBLIC

{Public declarations} END;

VAR

Form4: TFORM4; IMPLEMENTATION

Uses Unit5, DB; // Reference DataModule The unit where the unit is located; {$ r * .dfm} end.

Setting the TDBNAVIGATOR, the property of the DataSource of the TDBGRI control is DMDemo1.dsdemo1, where DMDemo1 is the name of the data module, and DSDemo1 is the name of the TDataSource control in the data module. Active TclientDataSet's Active property is True, the Form form obtains the following screen.

Compiling the project group to copy the client program to any computer on the network, all can be executed. A number of web services is done.

References: actual Delphi6 / Kylix2: SOAP / Web Service programming chapter, the author: Levi example of this design mostly from the book, as well as some of the names of controls

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

New Post(0)