unit fMain;

interface

uses
  System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
  WEBLib.Forms, WEBLib.Dialogs, XData.Web.Client, XData.Web.Connection, Data.DB,
  XData.Web.JsonDataset, XData.Web.Dataset, Vcl.Controls, Vcl.Grids,
  WEBLib.DBCtrls, WEBLib.DB, WEBLib.Grids;

type
  TForm1 = class(TWebForm)
    XDataWebDataSet1: TXDataWebDataSet;
    XDataWebConnection1: TXDataWebConnection;
    XDataWebClient1: TXDataWebClient;
    WebDataSource1: TWebDataSource;
    XDataWebDataSet1Id: TIntegerField;
    XDataWebDataSet1Name: TStringField;
    XDataWebDataSet1Country: TStringField;
    WebDBTableControl1: TWebDBTableControl;
    procedure WebFormCreate(Sender: TObject);
    procedure XDataWebConnection1Connect(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WebFormCreate(Sender: TObject);
begin
  XDataWebConnection1.Connected := True;
end;

procedure TForm1.XDataWebConnection1Connect(Sender: TObject);
begin
  XDataWebClient1.RawInvoke('ICustomerService.GetCustomers', [],
    procedure(Response: TXDataClientResponse)
    begin
      XDataWebDataset1.Close;
      XDataWebDataset1.SetJsonData(TJSObject(Response.Result)['value']);
      XDataWebDataset1.Open;
    end
  );
end;

end.
