Topic: Gzip compression with SOAP

Hi everyone.

I was wondering if there was a way to request a compressed XML response from a web service. This is a segment of my code, involving contact with the WS:

require "soap/wsdlDriver"

factory = SOAP::WSDLDriverFactory.new(url)
driver = factory.create_rpc_driver
res = driver.Search(ws_params)

This works fine. However, I would like to speed up my app by using soap compression, and so far I haven't been lucky searching the web for a way to do so.
I hope someone can give me a hand here.
Thank you very much and regards.

Re: Gzip compression with SOAP

How to Compress Your SOAP Requests Using GZIP
Applies To
1. Axis2/Java 1.3 or later
2. JDK 1.4 or later
Why Compress Requests?
Compressing SOAP requests might be a good idea if your SOAP message is large and/or when you want to reduce network bandwidth usage. Implementations of the HTTP protocol enable the use of GZip as a standard way of compressing requests sent over it.
Enabling Compression
Axis2 uses the HTTP implementation from Apache Commons HttpClient project. It is very easy to compress your requests using the Axis2 client API.
You just have to set the following property,
org.apache.axis2.transport.http.HTTPConstants.MC_GZIP_REQUEST
to:
Boolean.TRUE
using the Options object used by your client object.
The following shows how you can do this in your client code.
//get the Options object used by your client
Option options = client.getOptions();
//set the property
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
Once you set this property, Axis2 not only makes sure your request is compressed using GZip, but also adds the proper content encoding headers so that the receiving end can decode the message correctly.
i.e.
Content-Encoding: gzip
Axis2 HTTP transport listeners can handle GZip requests, without any additional configuration, if the proper HTTP headers are present.

Re: Gzip compression with SOAP

As arnoldclab alludes to, you must remember that this won't necessarliy make your application faster - you are trading CPU time on compression for network time on transmission. Usually this is a good trade, as networks are far slower than CPUs, but you may need to factor in extra CPU horsepower if this is a busy application...