Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to pass interface type to procedure

Tags:

how to I pass interface type to over procedure parameter ?

type
    Hello_PortType = interface(ISoapInvokable)
      ['{243CBD89-8766-F19D-38DF-427D7A02EAEE}']
        function GetDeneme(s: string): string;
      end;

SoapCall(Hello_PortType , 'http://localhost:8080/wsdl/ITDeneme');

then how to get TypeInfo using with saopcall method variable ?

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;
like image 731
serkan güneş Avatar asked Mar 13 '19 08:03

serkan güneş


1 Answers

You need to specify the TypeInfo() pointer, not the interface type.

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');
...

Don't use a variant here - it doesn't make any sense, since you expect an interface type, not an interface instance.

like image 78
Arnaud Bouchez Avatar answered Nov 15 '22 04:11

Arnaud Bouchez