Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Delphi web-services work ? ( Adding method in runtime ?? )

I've created web-service in Delphi XE using WSDL importer. Delphi generated for me module ITransmitter1.pas with ITransmitter interface and GetITransmitter function.

To use webservice i use:

var Transmitter: ITransmitter;
begin
  Transmitter := GetITransmitter(True, '', nil);
  Transmitter.Transmit(Memo1.Text, OutXML);
end;

But i cant see anywhere body of method Transmit ...

In ITransmitter.pas i see:

  InvRegistry.RegisterInterface(TypeInfo(ITransmitter), 'urn:TransmitterIntf-ITransmitter', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ITransmitter), 'urn:TransmitterIntf-ITransmitter#Transmit');

If i comment this lines i get "interface not supported" error. As i see here delphi is adding method in RunTime ! How does it work ? Can i add method in runtime to my own class ?

like image 980
Astronavigator Avatar asked Dec 02 '25 16:12

Astronavigator


1 Answers

If you created a web service client with the WSDL importer, the generated client code will invoke a method on the server. So in fact, the method 'body' (code) is on the web service server.

Delphi generates a Soap request based on the WSDL, and behind the scenes RTTI (introspection) is used to generate parameters etc. of the web service call as XML. This XML is sent to the server, which executes the method implementation and sends back a Soap response.

Things are opposite if you create the web service server, in this case the Delphi application of course needs to implement all method bodies.

like image 83
mjn Avatar answered Dec 04 '25 06:12

mjn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!