SOAP and REST – Using GZip with Delphi client

I did some testing with delphi clients and a Java server. We are deciding between SOAP and REST. I’ve implemented client applications in Delphi using GZip. It is a very simple implementation and it brings a great result. The larger the volume of data, greater the difference using GZip compression. The bandwidth is also a factor that influences a lot.  Let’s see the implementations.


Implementation of compression with REST is extremely simple. It’s just a matter of correctly setting the “Compressor” attribute of the  TIDHttp component. I’m using TIdCompressorZLib.

IdHttp := TIdHTTP.Create(nil);
IdHttp.Compressor := TIdCompressorZLib.Create(IdHttp);

NOTE: This does not work in Delphi XE2. Access violation occurs. Works in XE3.


Implementation with SOAP is a bit more complicated. For my tests I used the THTTPrio component events.

procedure HTTPRIOHTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp; 
  Data: Pointer);
  contentEncodingHeader = 'Accept-Encoding: gzip, deflate';
  Flag: LongBool;
  Flag := True;
  HttpAddRequestHeaders(Data, PChar(contentEncodingHeader), 
    Length(contentEncodingHeader), HTTP_ADDREQ_FLAG_ADD);
    PChar(@Flag), SizeOf(Flag));


These tests were done in order to compare the implementation of SOAP and REST.  I used the framework developed by a brazilian programmer, Fabricio Colombo, the Delphi REST Client API. Tests were performed with a bandwidth limited to 512 Kbps. Information is in milliseconds. GZIP-Results Delphi - Normal_vs_GZip

The difference with GZip is big. Do not be fooled by the chart! It’s a logarithmic scale.

5 thoughts on “SOAP and REST – Using GZip with Delphi client

    • This occurs only with SOAP. I did a profiling and noticed that the bottleneck is in a windows dll (msxml). I did a test with an .NET application and interestingly, he does not use this DLL. It must be something very old library from Microsoft.

      Using REST, the performance from Delphi and Java is similar.

  1. Olá Roberto! Estou fazendo alguns testes com interfaces do mORMot com o C# (na verdade com Oxygene) e verifiquei no forum do mORMot que você também tentou com o C#, gostaria de saber se teve sucesso ou se teria alguma dica/código, e caso não tenha conseguido eu posso também repassar conhecimento. Se puder responder ao meu email eu agradeço. Abs.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s