sql server 2008 - How to consume TDatasource Component by coding returned through delphi webservice in a delphi VLC Form -
i have made cgi web service. code below:
unit myservicesimpl; interface uses soap.invokeregistry, system.types, soap.xsbuiltins, myservicesintf, data.db, data.sqlexpr, sqlconnection1, data.win.adodb; type { tmyservices } tmyservices = class(tinvokableclass, imyservices) public function testfunction(): tadodataset; stdcall; end; var connstring: string; objtadoquery: tadoquery; objtsqlds: tdatasource; objds: tadodataset; objtable :tadotable; implementation function tmyservices.testfunction: tadodataset; var objtsqlconnection1: tadoconnection; var constr: string; begin objtsqlconnection1 := tadoconnection.create(nil); constr := 'provider=sqloledb;' + 'data source=kays-serv64-01;' + 'initial catalog=test;' + 'user id=sa;password=kays@india'; objtsqlconnection1.connectionstring := constr; objtsqlconnection1.loginprompt := false; objtsqlconnection1.connected := true; if (objtsqlconnection1.connected) begin objtadoquery := tadoquery.create(nil); objtsqlds := tdatasource.create(nil); objds:= tadodataset.create(nil); objtable:= tadotable.create(nil); objtable.tablename:='expediads'; objtadoquery.connection := objtsqlconnection1; objtadoquery.sql.text := 'select * expediads'; objtadoquery.prepared := true; objtadoquery.active := true; objtsqlds.dataset := objtadoquery; objds.datasource:=objtsqlds; result := objds; end else begin result := objds; end; end; initialization { invokable classes must registered } invregistry.registerinvokableclass(tmyservices); end.
now trying consume webservice, have used wsdl imported. when used like:
procedure tform3.testfunction; var vmyservice: imyservices; var objdatasource: tdatasource; var objnewds: imyservices1.tadodataset; var objtsqlconnection1: tadoconnection; var constr: string; begin vmyservice := getimyservices; objnewds :=vmyservice.testfunction(); end;
the test function returns imyservice1.tadodataset nad hence not compatible data.db.tadodataset. please help.
you cannot tadodataset
cannot remoted need tadoconnection
, such things connectionstring
on client on server.
the way remove data using delphi using datasnap tsoapdatamodule
on server side containing tclientdataset
gets populated tadodataset
using tdatasetprovider
, , on client side tsoapconnection
plus tclientdataset
on client.
datasnap perform read/update traffic using soap (i.e. xml on http).
see datasnap videos pawel glowacki idea on how set up, read documentation @ creating multi tiered applications index.
note datasnap, need have delphi enterprise minimum edition, , won't work cgi webservices.
another solution (less options, gets data across server client), expose tclientdataset
's internal data xml, provide through method on cgi web service, on client side put xml tclientdataset
again.
i'm not sure if within delphi licensing terms (they might prohibit using tclientdataset
doing multi-tier work), should work.
Comments
Post a Comment