如何将接口类型传递给过程参数?
type
Hello_PortType = interface(ISoapInvokable)
['{243CBD89-8766-F19D-38DF-427D7A02EAEE}']
function GetDeneme(s: string): string;
end;
SoapCall(Hello_PortType , 'http://localhost:8080/wsdl/ITDeneme');
那么如何使用 saopcall 方法变量来获取 TypeInfo 呢?
function TLib.SoapCall(Intf: Variant; Addr: string): ISoapInvokable;
var
RIO: THTTPRIO;
begin
InvRegistry.RegisterInterface(TypeInfo(Intf), 'urn:DenemeIntf-IDeneme', ''); //-- type info doesn't work with variant
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(Intf), 'GetDeneme');
Result := nil;
if Addr = '' then
exit();
RIO := THTTPRIO.Create(nil);
try
Result := RIO as ISoapInvokable;
RIO.URL := Addr;
finally
if (Result = nil) then
RIO.Free;
end;
end;
您需要指定TypeInfo()
指针,而不是接口类型。
SoapCall(TypeInfo(Hello_PortType) , 'http://localhost:8080/wsdl/ITDeneme');
function TLib.SoapCall(TypInfo: pointer; Addr: string): ISoapInvokable;
var
RIO: THTTPRIO;
begin
InvRegistry.RegisterInterface(TypInfo, 'urn:DenemeIntf-IDeneme', '');
InvRegistry.RegisterDefaultSOAPAction(TypInfo, 'GetDeneme');
...
不要在这里使用变体 - 它没有任何意义,因为您期望的是接口类型,而不是接口实例。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)