Logo New book: Delphi 2007 Handbook
My blog in online
Delphi tech support service: support.marcocantu.com
Google
  Web www.marcocantu.com

Menu for Development

Site Menu
Delphi 2007 Handbook
Mastering Borland Delphi 2005
Essential Pascal
Essential Delphi
Buy Books Online
Code Repository
Newsgroups
White Papers
Tools
Conferences
Training
Delphi Links
Contact Marco

My Other Sites
Italian Site (www.marcocantu.it)
Developers Newsgroups Browser (dev.newswhat.com)
My town (www.piazzacavalli.net)
the delphi search
Wintech Italia (my company)

Breaking News
Buy Mastering Borland Delphi 2005 from Amazon
Free ebook: Mastering Delphi Update for Delphi 2006

Advertising
Home My Blog Books My Bookstore Development Links Marco


Home: Code Repository: Mastering Delphi 6

Chapter 23 - Project SoapDataClient

Project Structure

SoapDataClient.dpr
program SoapDataClient;

uses
  Forms,
  SoapDataForm in 'SoapDataForm.pas' {FormSDC},
  SoapServerIntf in 'SoapServerIntf.pas';

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TFormSDC, FormSDC);
  Application.Run;
end.
SoapDataForm.pas
unit SoapDataForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, DBClient, SoapConn, Grids, DBGrids, StdCtrls, SoapServerIntf,
  Rio, SoapHTTPClient;

type
  TFormSDC = class(TForm)
    SoapConnection1: TSoapConnection;
    ClientDataSet1: TClientDataSet;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    Button1: TButton;
    Button2: TButton;
    HTTPRIO1: THTTPRIO;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormSDC: TFormSDC;

implementation

{$R *.dfm}

procedure TFormSDC.Button1Click(Sender: TObject);
begin
  ClientDataSet1.Open;
end;

procedure TFormSDC.Button2Click(Sender: TObject);
begin
  ClientDataSet1.ApplyUpdates (-1);
end;

procedure TFormSDC.Button3Click(Sender: TObject);
var
  ISoapData: ISoapTestDm;
begin
  // CURRENTLY DOESN'T WORK!
  ISoapData := HttpRio1 as ISoapTestDm;
  ShowMessage (IntToStr (ISoapData.GetRecordCount));
end;

end.
SoapServerIntf.pas
unit SoapServerIntf;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, DBClient, SoapConn, Grids, DBGrids, StdCtrls,
  Rio, SoapHTTPClient, Midas, InvokeRegistry;

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

implementation

initialization
  InvRegistry.RegisterInterface(TypeInfo(ISoapTestDm));

end.
SoapDataForm.dfm
object FormSDC: TFormSDC
  Left = 457
  Top = 113
  Width = 480
  Height = 252
  Caption = 'SoapDataClient'
  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
  object DBGrid1: TDBGrid
    Left = 8
    Top = 40
    Width = 457
    Height = 177
    DataSource = DataSource1
    TabOrder = 0
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
  end
  object Button1: TButton
    Left = 88
    Top = 8
    Width = 75
    Height = 25
    Caption = 'Open'
    TabOrder = 1
    OnClick = Button1Click
  end
  object Button2: TButton
    Left = 168
    Top = 8
    Width = 75
    Height = 25
    Caption = 'Do Update'
    TabOrder = 2
    OnClick = Button2Click
  end
  object Button3: TButton
    Left = 8
    Top = 8
    Width = 75
    Height = 25
    Caption = 'Count'
    Enabled = False
    TabOrder = 3
    OnClick = Button3Click
  end
  object SoapConnection1: TSoapConnection
    URL =
       'http://localhost:1024/SoapDataServer.SoapDataServer/Soap/ISoapTe' +
      'stDm'
    Left = 56
    Top = 24
  end
  object ClientDataSet1: TClientDataSet
    Aggregates = <>
    Params = <>
    ProviderName = 'DataSetProvider1'
    RemoteServer = SoapConnection1
    Left = 152
    Top = 24
  end
  object DataSource1: TDataSource
    DataSet = ClientDataSet1
    Left = 240
    Top = 24
  end
  object HTTPRIO1: THTTPRIO
    URL =
       'http://localhost:1024/SoapDataServer.SoapDataServer/Soap/ISoapTe' +
      'stDm'
    HTTPWebNode.Agent = 'Borland SOAP 1.1'
    HTTPWebNode.UseUTF8InHeader = False
    Converter.Options = [soSendMultiRefObj, soTryAllSchema]
    Left = 56
    Top = 88
  end
end