开发者

OpToSoapDomComv.TRefCache.FNodes contains references to non-existing XMLNodes

In our D2007 application we are using a Webservice, accessed with a THTTPRI开发者_开发技巧O object. When the TDatamodule containing the THTTPRIO object is Destroyed an access violation occurs.

This AV is raised when the TSoapDOMConvert is freed, which in turn executes:

TRefCache(RefMap[0].Instance).Free

calling

destructor TRefCache.Destroy;
begin
  FHREFs.Free;
  FMHREFs.Free;
  FNodes := nil; //Causes AV
end;

FNodes is a TInterfaceList containing one reference to IXMLNodes, but the object seems to have been freed before all this.

Does anyone know this problem? How to solve it?

[Edit]More info on the usage of the RIO object The THTTPRIO object is only used in the following call to the webservice:

 LIResult.Assign((Rio as IWSLicenseIntf).CheckLicense(FLicenseInfo)); 

The LIResult object is freed later on.


THTTPRIO has two different lifetime-management schemes. One as a Component and one as an Interface. Mixing them is a bad idea. This could be your problem.

Jean-Marie Babet commented on this here. http://www.delphigroups.info/2/11/344722.html

The source file generated from the WSDL should have a function called GetIWSLicenseIntf (or similar). Try to use that instead of the Rio component. Change (Rio as IWSLicenseIntf) to GetIWSLicenseIntf() and add parameters UseWSDL and URL if necessary.

Another option would be something like this

var
  WSLic: IWSLicenseIntf;
  RIO: THTTPRIO;
begin
  RIO := THTTPRIO.Create(nil);
  RIO.URL := 'www.whatever.com';
  WSLic := RIO as IWSLicenseIntf;
  LIResult.Assign((WSLic).CheckLicense(FLicenseInfo)); 
end;

Interfaces in Delphi is reference counted so you should not free WSLic and not free RIO. It will be freed for you when WSLic goes out of scope. The code is of course not tested since I do not have your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜