Unit uTest;<br><br>interface<br><br>uses SysUtils, Classes, InvokeRegistry, Midas, SOAPMidas, SOAPDm, Provider, IniFiles,<br> DB, DBTables,DBClient;<br><br>type<br> Itest = interface(IAppServerSOAP) //IInvokable IAppServerSOAP<br> ['{583E1D57-AD4B-4D0C-8CD0-C39DC77A94AA}']<br> Function sFunIniProvider(Name : string) : Boolean ; StdCall;<br> procedure preGetProvider; StdCall;<br> end;<br><br> TTest = class(TSoapDataModule, Itest, IAppServerSOAP, IAppServer)<br> qrM: TQuery;<br> dspM: TDataSetProvider;<br> private<br> public<br><br> Function sFunIniProvider(Name : string) : Boolean ; StdCall;<br> procedure preGetProvider; StdCall;<br> <br> end;<br><br>implementation<br> uses Connect, ServerDll;<br>var<br> testPro : TDataSetProvider;<br> testQr : TQuery;<br><br>{$R *.DFM}<br><br>procedure TtestCreateInstance(out obj: TObject);<br>begin<br> obj := Ttest.Create(nil);<br>end;<br><br>{ Tdbest }<br><br>function TTest.sFunIniProvider(Name: string): Boolean;<br>begin<br> if FindComponent('dsp'+Name) = nil then<br> begin<br> if FindComponent('qr'+Name) = nil then<br> begin<br> try<br> testQr := TQuery.Create(Self);<br> except<br> result := false;<br> Exit;<br> End;<br> testQr.Name := 'qr'+Name;<br> testQr.DatabaseName := 'hnjtBase';<br> testQr.SQL.Text := Uppercase('select * from zxy_TestM');<br> end;<br> try<br> testPro := TDataSetProvider.Create(Self);<br> except<br> result := false;<br> Exit;<br> End;<br> testPro.Name := 'dsp'+Name;<br> testPro.DataSet := testQr;<br> testPro.Exported := true;<br> testPro.Constraints := true;<br> Self.RegisterProvider(testPro);<br> end;<br><br> Result := True;<br>end;<br><br>procedure TTest.preGetProvider;<br>var<br> Fileini : TInifile;<br> i : Integer;<br>begin<br> try<br> FileIni:=tinifile.Create('D:/Provider.ini');<br> except<br> End;<br> For i := 0 to Self.ComponentCount - 1 do<br> Fileini.WriteString('Provider','Pro'+ IntToStr(i),Self.Components.Name);<br> FileIni.Free;<br>end;<br><br>initialization<br> dmConnect := TdmConnect.Create(Nil);<br> InvRegistry.RegisterInvokableClass(TTest, TtestCreateInstance);<br> InvRegistry.RegisterInterface(TypeInfo(Itest));<br>finalization<br> dmConnect.Free;<br>end.