【发布时间】:2019-03-13 08:04:46
【问题描述】:
如何将接口类型传递给过程参数?
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;
【问题讨论】:
-
我猜你的代码不会编译。
Hello_PortType是接口类型,不是接口实例,所以不能转换成变体。