How to Compress Your SOAP Requests Using GZIP

This document explains how to compress SOAP requests to other Web services endpoints, using the Axis2 client API.

Date: Tue, 1st Jan, 2008
Level: Introductory
Reads: 9009 Comments: 0 | Login or register to post comments
Eran Chinthaka
Software Engineer
WSO2 Inc.
chinthaka's picture

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.

 

Author : Eran Chinthaka, Member-Apache Software Foundation. eran(dot)chinthakaXgmail.com, where X=@

 

library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)