SOAP Compression for Apache Axis 1.X
Axis can be extended with this transport sender to support the compression of SOAP messages. The sizes of SOAP messages are dramatically reduced resulting in faster transmission over slow network connections. The extension is easy to install and can be used for free.
The sender only covers compression and decompression on the client side. However, it can be combined with features of the Web container or a servlet filter. It is not necessary to change Axis itself to use SOAP compression.
The sender is included in the library soap-compression-1.2.jar. This library has to be included into the classpath. After the sender's class is available, Axis must be configured to use the gzip compression sender instead of the HTTP sender. On startup, an Axis client looks for a configuration file named client-config.wsdd in the current directory and in the classpath. To replace the sender, the file client-config.wsdd with a transport element should be used (see below). The easiest way to achieve this is to place the file in the directory where the Axis client is started.
The compression sender is compatible with Axis 1.1 or newer. The configuration is different depending on which version of Axis is used. The difference lies in how parameters are declared in the file client-config.wsdd. These parameters can switch the compression of HTTP requests and decompression of HTTP responses on and off.
Setting the parameter compressRequest to true turns on the compression of requests. Setting the parameter acceptEncodingHeader to true asks the server to compress responses.
Depending on your Axis version, you can read one of the two paragraphs that follow.
Axis 1.2 Beta or Newer
The configuration for these versions is straightforward compared to Axis 1.1. A sample client-config.wsdd is shown below.
<?xml version="1.0" encoding="UTF-8"?> <deployment name="defaultClientConfig" xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <transport name="http" pivot="java:com.osmoticweb.soapcompression.CompressionHTTPSender"> <parameter name="compressRequest" value="true"/> <parameter name="acceptEncodingHeader" value="true"/> </transport> <transport name="local" pivot="java:org.apache.axis.transport.local.LocalSender"/> <transport name="java" pivot="java:org.apache.axis.transport.java.JavaSender"/> </deployment>
An Axis 1.1 transport handler cannot read parameters inside the corresponding configuration. For this reason a handler is needed to pass the parameters to the transport sender. A suitable handler is included in the SOAP compression library. A sample configuration for Axis 1.1 is shown below.
<?xml version="1.0" encoding="UTF-8"?> <deployment name="defaultClientConfig" xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> <transport name="http" pivot="java:com.osmoticweb.soapcompression.CompressionHTTPSender"> <requestFlow> <handler type="java:com.osmoticweb.soapcompression.PutOptionsHandler"> <parameter name="compressRequest" value="true"/> <parameter name="acceptEncodingHeader" value="true"/> </handler> </requestFlow> </transport> <transport name="local" pivot="java:org.apache.axis.transport.local.LocalSender"/> <transport name="java" pivot="java:org.apache.axis.transport.java.JavaSender"/> </deployment>
Tomcat's standalone HTTP connector supports only the compression of the HTTP response. To use this feature, the attribute compression has to be specified in the configuration file server.xml. Details can be found in the connector's documentation. A sample configuration for the HTTP connector is shown below.
<Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata" compressableMimeType="text/html,text/xml"/>
If Tomcat is used behind a Web server, the AJP connector has to be used instead. Unfortunately, the AJP connector has no compression support. Instead, the compression features of the Web server can be used.
Regardless of the connector, Tomcat can compress requests and responses if a Servlet filter is used.
Any Servlet 2.3 Compliant Container
A servlet filter can be placed into the response and request flow of any Servlet 2.3 compliant Web container. The filter can do the compression and decompression. Most compression filters compress only the response and are not able to decompress a request. This is fine for most Web applications because the request is tiny compared to the response. SOAP request messages are usually much larger. Depending on the application, the request messages can be several times larger than the response messages. For this reason, we have developed a servlet compression filter to use with the SOAP protocol. This filter compresses the request and decompresses the response.
How it Works
The sender compresses the content of the HTTP message and indicates the compression algorithm in the Content-Encoding header field. If the option acceptEncodingHeader is set to true, the sender adds an Accept-Encoding header field indicating that the client accepts a gzip encoded response.
If the response from the server has a Content-Encoding HTTP header field with gzip as the value, the response is decompressed.
This software is based on source code from the Apache Axis Project
Use of this software is free of charge for both personal and commercial purposes.
predic8 HEREBY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, RELATIVE TO THE SOFTWARE, INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR MERCHANTIBILITY. predic8 SHALL NOT BE LIABLE OR RESPONSIBLE FOR ANY DAMAGES, INJURIES OR LIABILITIES CAUSED DIRECTLY OR INDIRECTLY FROM THE USE OF THE SOFTWARE, INCLUDING BUT NOT LIMITED TO INCIDENTAL, CONSEQUENTIAL OR SPECIAL DAMAGES.