Marco's Web Center

Menu for Development

Site Menu
Object Pascal Handbook
Delphi Handbooks Collection
Mastering Borland Delphi 2005
(Old) White Papers
(Old)Tools
(Old) Conferences

My Other Sites
Italian Site (www.marcocantu.it)
the delphi search

Spirit of delphi

Advertising
Home My Blog Books Object Pascal Marco

Home: Code Repository: Mastering Delphi 6

Chapter 23 - Project SoapDataServer

Project Structure

SoapDataServer.dpr
program SoapDataServer;

{$APPTYPE GUI}

uses
  Forms,
  ComApp,
  ServerForm in 'ServerForm.pas' {Form1},
  ServerWebModule in 'ServerWebModule.pas' {WebModule2: TWebModule},
  ServerDataModule in 'ServerDataModule.pas' {SoapTestDm: TSoapDataModule};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TWebModule2, WebModule2);
  Application.Run;
end.
ServerForm.pas
unit serverform;

interface

uses
  SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses ComApp;

{$R *.DFM}

const
  CLASS_ComWebApp: TGUID = '{833BAD2A-CA3F-4194-A0BA-FD57D46EDC16}';

initialization
  TWebAppAutoObjectFactory.Create(Class_ComWebApp,
    'SoapDataServer', 'SoapDataServer Object');

end.
ServerWebModule.pas
unit serverwebmodule;

interface

uses
  SysUtils, Classes, HTTPApp, WSDLPub, SOAPPasInv, SOAPHTTPPasInv,
  SoapHTTPDisp, WebBrokerSOAP;

type
  TWebModule2 = class(TWebModule)
    HTTPSoapDispatcher1: THTTPSoapDispatcher;
    HTTPSoapPascalInvoker1: THTTPSoapPascalInvoker;
    WSDLHTMLPublish1: TWSDLHTMLPublish;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  WebModule2: TWebModule2;

implementation

uses WebReq;

{$R *.DFM}

initialization
  WebRequestHandler.WebModuleClass := TWebModule2;

end.
ServerDataModule.pas
Unit serverdatamodule;

interface

uses
  SysUtils, Classes, InvokeRegistry, Midas, SOAPMidas, SoapDm, Provider,
  DB, DBTables, DBXpress, FMTBcd, SqlExpr;

type
  ISoapTestDm = interface(IAppServer)
    ['{1F109687-6D8B-4F85-9BF5-EFFC87A9F10F}']
    function GetRecordCount: Integer;
  end;

  TSoapTestDm = class(TSoapDataModule, ISoapTestDm, IAppServer)
    DataSetProvider1: TDataSetProvider;
    SQLConnection1: TSQLConnection;
    SQLDataSet1: TSQLDataSet;
    SQLDataSet2: TSQLDataSet;
  private

  public
    function GetRecordCount: Integer;
  end;

implementation

{$R *.DFM}

procedure TSoapTestDmCreateInstance(out obj: TObject);
begin
  obj := TSoapTestDm.Create(nil);
end;

{ TSoapTestDm }

function TSoapTestDm.GetRecordCount: Integer;
begin
  // read in the record count by running a query
  SQLDataSet2.Open;
  Result := SQLDataSet2.Fields[0].AsInteger;
  SQLDataSet2.Close;
end;

initialization
   InvRegistry.RegisterInvokableClass(TSoapTestDm, TSoapTestDmCreateInstance);
   InvRegistry.RegisterInterface(TypeInfo(ISoapTestDm));
end.
ServerForm.dfm
object Form1: TForm1
  Left = 192
  Top = 107
  Width = 234
  Height = 153
  Caption = 'SoapDataServer'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
end
ServerWebModule.dfm
object WebModule2: TWebModule2
  OldCreateOrder = False
  Actions = <>
  Left = 271
  Top = 114
  Height = 177
  Width = 493
  object HTTPSoapDispatcher1: THTTPSoapDispatcher
    Dispatcher = HTTPSoapPascalInvoker1
    WebDispatch.PathInfo = 'soap*'
    Left = 64
    Top = 48
  end
  object HTTPSoapPascalInvoker1: THTTPSoapPascalInvoker
    Converter.Options = [soSendMultiRefObj, soTryAllSchema]
    Left = 208
    Top = 48
  end
  object WSDLHTMLPublish1: TWSDLHTMLPublish
    WebDispatch.MethodType = mtAny
    WebDispatch.PathInfo = 'wsdl*'
    AdminEnabled = False
    Left = 352
    Top = 48
  end
end
ServerDataModule.dfm
object SoapTestDm: TSoapTestDm
  OldCreateOrder = True
  Left = 193
  Top = 452
  Height = 159
  Width = 269
  object DataSetProvider1: TDataSetProvider
    DataSet = SQLDataSet1
    Constraints = True
    Left = 80
    Top = 24
  end
  object SQLConnection1: TSQLConnection
    Connected = True
    ConnectionName = 'IBLocal'
    DriverName = 'Interbase'
    GetDriverFunc = 'getSQLDriverINTERBASE'
    LibraryName = 'dbexpint.dll'
    LoginPrompt = False
    Params.Strings = (
      'BlobSize=-1'
      'CommitRetain=False'

              'Database=c:\program files\interbase corp\interbase6\examples\dat' +
        'abase\employee.gdb'
      'DriverName=Interbase'
      'Password=masterkey'
      'RoleName=RoleName'
      'ServerCharSet=ASCII'
      'SQLDialect=1'
      'Interbase TransIsolation=ReadCommited'
      'User_Name=sysdba'
      'WaitOnLocks=True')
    VendorLib = 'GDS32.DLL'
    Left = 152
    Top = 24
  end
  object SQLDataSet1: TSQLDataSet
    SQLConnection = SQLConnection1
    CommandText = 'select * from EMPLOYEE'
    Params = <>
    Left = 80
    Top = 72
  end
  object SQLDataSet2: TSQLDataSet
    SQLConnection = SQLConnection1
    CommandText = 'select count(*) from EMPLOYEE'
    Params = <>
    Left = 152
    Top = 72
  end
end