You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ws.apache.org by Apache Wiki <wi...@apache.org> on 2006/01/05 12:10:14 UTC

[Ws Wiki] Update of "FrontPage/Axis/GzipCompression" by CyrilleLeClerc

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Ws Wiki" for change notification.

The following page has been changed by CyrilleLeClerc:
http://wiki.apache.org/ws/FrontPage/Axis/GzipCompression

The comment on the change is:
How to enable gzip compression 

New page:
'''How to use Gzip compression with Axis ? '''

'''Client Side'''

On the client side, you need to use the {{{CommonsHTTPSender}}} (instead of the default {{{HTTPSender}}} ) and you have to set to {{{true}}} the properties {{{HTTPConstants.MC_GZIP_REQUEST}}} and {{{HTTPConstants.MC_ACCEPT_GZIP}}} to respectively compress the request and tell the server it can compress the response

 * To use {{{CommonsHTTPSender}}}, create a client-config.wsdd (sample [attachment:client-config.wsdd here]) at the root of your classpath like this :
 {{{
<?xml version="1.0" encoding="UTF-8"?> 

<deployment 
    name="commonsHTTPConfig" 
    xmlns="http://xml.apache.org/axis/wsdd/" 
    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

  <!-- use CommonsHTTPSender instead of the default HTTPSender -->
  <transport name="http" pivot="java:org.apache.axis.transport.http.CommonsHTTPSender" />  

  <transport name="local" pivot = "java:org.apache.axis.transport.local.LocalSender" /> 
  <transport name="java" pivot="java:org.apache.axis.transport.java.JavaSender" /> 
</deployment>
}}}

 * To define {{{MC_GZIP_REQUEST}}} and {{{MC_ACCEPT_GZIP}}}, you can code it like this :
 {{{
VersionSoapBindingStub binding = (VersionSoapBindingStub) new VersionServiceLocator()
    .getVersion();

// Compress the request
binding._setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
// Tell the server it can compress the response
binding._setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);

// invoke the service
String result = binding.getVersion();
}}}

(!) If you get in your client an exception {{{org.xml.sax.SAXParseException: Content is not allowed in prolog.}}}, it means that you activated the compression of the request when the server does not support it. You should then enable server side support of request compression or disable client side compression of the request (removing {{{binding._setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);}}})


'''Server Side '''
 * To activate compression of the request
  * '''todo : describe how to enable it in Tomcat, Apache Httpd, IIS'''
  * Osmotic``Web has a sample with a {{{ServletFilter}}} [http://www.osmoticweb.com/gzip-compression-filter.htm here]

 * To activate compression of the response
  * Tomcat : update in {{{server.xml}}} the {{{<transport>}}} element to define the attributes {{{compression}}}, {{{compressionMinSize}}}, {{{noCompressionUserAgents}}} and {{{compressableMimeType}}} like this

   {{{
...
<Connector
           port="8080" maxHttpHeaderSize="8192"
           maxThreads="150" minSpareThreads="2" maxSpareThreads="75"
           enableLookups="false" redirectPort="8443" 
           acceptCount="100" connectionTimeout="20000" 
           disableUploadTimeout="true"
           compression="on" compressionMinSize="1" 
           noCompressionUserAgents="gozilla, traviata" 
           compressableMimeType="text/html,text/xml"
           />
...
}}}
  * Apache Httpd : use mod_deflate as described [http://httpd.apache.org/docs/2.2/mod/mod_deflate.html here]
   '''todo : write a small tutorial "How to enable mod_deflate in Apache Httpd" or refer to an existing one'''
  * Microsoft IIS : '''todo'''

'''Further readings'''
 * Osmotic``Web developped an add-on to support GZip compression in Axis client before this feature was integrated in Axis 
  http://www.osmoticweb.com/axis-soap-compression.htm
 * RFC "2616 :  Hypertext Transfer Protocol -- HTTP/1.1", section "3.5 Content Codings", see {{{Content-Encoding: gzip}}}
  http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5