function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JasonRogersJasonRogers 

Increasing performance of Soap requests

I wonder if there is a way today to indicate that I want responses from Salesforce to be in a zipped format. On the same token, is there a way to send zipped request to Salesforce? This would greatly reduce the network bandwidth requirements.

Thanks.
DevAngelDevAngel

Hi Jason,

sforce supports the http1.1 compression specification.  The problem is, there are very few (if any) soap stacks that include support for this option.  For .Net we have published on tech note on this subject (to be revised to reflect the current technology in the coming weeks) and I hope to publish a tech note on how to implement this is Java in the coming weeks as well.

The Java case will be specific to Apache Axis and requires a modification to the Axis libraries to work.  The general idea is to add an http header on the outbound call indicating that the request is zipped (Content-Encoding: gzip).  This will let the service know to unzip the soap message before trying to process it.  To get the message zipped, you need to intercept the message just before it goes out over the wire.  This is done in the HTTPTransport class in the WriteToSocket method.  Axis examines the objects that are to be sent in the soap message and serializes these to an xml representation.  It then sends the xml representation over the wire.  So just before the xml is sent, you need to zip it using the java gzip libraries.

To obtain a zipped response you add an http header indicating that you can accept a zipped response (Accept-Encoding: gzip).  Out of the box Axis does not check to see if the response is zipped, so you need to get the message before Axis tries to deserialize it.  This is done in the HTTPTransport class during the execution of the ReadFromSocket (I think) method.  Axis reads the stream from the socket, and you need to unzip the data then replace the original stream with the unzipped stream.  You can then allow Axis to continue with it's normal processing.

The obvious problem that arises is the lack of support out of the box means that you have to crack open the Axis source, modify it, hope you didn't break anything, recompile it and make sure you reference your modified library rather than the distribution.  If you go to a new environment, add a team member, etc., you need to make sure you are using the modified Axis libs.

Hopefully, the tech note will ease the process a bit.

Cheers

JasonRogersJasonRogers
This sounds pretty straight forward. Thanks for the tip!

- Jason