用delphi开发webservice服务器端程序,定义一个全局变量test和两个全局对象WordDocument1、WordApplication1,调用方先调用过程a1给三个对象赋值,马上读出没有问题,调用方再调用过程a2读取三个对象的值时,全局变量test可以读出,而两个全局对象WordDocument1、WordApplication1皆已失效,不知道是什么原因,诸位请帮帮忙,谢谢了。对应webservice的一个实例,调用方需要有不同的方法来访问,全局对象方式不成如何定义?
代码附下:{ Invokable implementation File for TReport which implements IReport }unit ReportImpl;interfaceuses InvokeRegistry, Types, XSBuiltIns, ReportIntf, SysUtils, Word2000, StdCtrls;type  { TReport }
  TReport = class(TInvokableClass, IReport)
  public
    procedure a1; stdcall;
    procedure a2; stdcall;               
  end;implementation
var
  test:string;
  WordDocument1: TWordDocument;
  WordApplication1: TWordApplication;
procedure TReport.a1; stdcall;
begin
  test:='这里赋初值';
  WordApplication1: TWordApplication.Create(nil);
  WordDocument1:=TWordDocument.Create(nil);
  {
  这里给WordDocument1和WordApplication1赋值
  }  showmessage(test);
  showmessage(WordApplication.name);
  showmessage(WordDocument1.name);
end;procedure TReport.a2; stdcall;
begin
  showmessage(test);
  showmessage(WordApplication.name);
  showmessage(WordDocument1.name);
end;
initialization
  { Invokable classes must be registered }
  InvRegistry.RegisterInvokableClass(TReport);end.