WebModule in Delphi SOAP Application Server



考虑到每个请求消息生成一个单独的线程,并且为每个线程动态创建Web模块的单独实例及其内容,我向Web模块添加了FDConnection和FDQuery,以便可以在请求时从数据库向请求者发送人员配置文件。如何访问web模块实例?

在web模块中只有一个web模块元类的变量:

var
WebModuleClass: TComponentClass = TWebModule1;

例如:

WebModule.FDQuery.Close;

CountryImpl单元是CountryIntf服务的实现

unit CountryImpl;
interface
uses Soap.InvokeRegistry, System.Types, Soap.XSBuiltIns, uCountry, CountryIntf,
WebModuleUnit1;
type
TCountryManager = class(TInvokableClass, ICountryManager)
public
function GetCountry(ACountryId: integer): TCountry;
end;
implementation

{ TCountry }
function TCountryManager.GetCountry(ACountryId: integer): TCountry;
begin
WebModule.FDQuery.Close;
WebModule.FDQuery.ParamByName('Id').Value := ACountryId;
WebModule.FDQuery.Open;
end;
initialization
InvRegistry.RegisterInvokableClass(TCountryManager);
end.

您的假设是不正确的:在SOAP服务器应用程序中只创建了一个web模块实例。你不应该在webmodule中添加特定于线程的功能,你必须把它添加到countryimpp .pas中。因为那里没有设计界面,所以你必须在该单元的函数中对FDConnection和FDQueries进行运行时实例化。

最新更新