|
Size: 3696
Comment: Clarify directions
|
← Revision 4 as of 2009-09-20 22:49:05 ⇥
Size: 3702
Comment: converted to 1.6 markup
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 7: | Line 7: |
| * To use {{{CommonsHTTPSender}}}, create a client-config.wsdd (sample [attachment:client-config.wsdd here]) at the root of your classpath like this : | * To use {{{CommonsHTTPSender}}}, create a client-config.wsdd (sample [[attachment:client-config.wsdd|here]]) at the root of your classpath like this : |
| Line 43: | Line 43: |
| * Osmotic``Web has a sample with a {{{ServletFilter}}} [http://www.osmoticweb.com/gzip-compression-filter.htm here] | * Osmotic``Web has a sample with a {{{ServletFilter}}} [[http://www.osmoticweb.com/gzip-compression-filter.htm|here]] |
| Line 62: | Line 62: |
| * Apache Httpd : use mod_deflate as described [http://httpd.apache.org/docs/2.2/mod/mod_deflate.html here] | * Apache Httpd : use mod_deflate as described [[http://httpd.apache.org/docs/2.2/mod/mod_deflate.html|here]] |
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 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, use _setProperty on your stub. Here is an example using Version :
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
OsmoticWeb has a sample with a ServletFilter 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 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
OsmoticWeb developped an add-on to support GZip compression in Axis client before this feature was integrated in Axis
RFC "2616 : Hypertext Transfer Protocol -- HTTP/1.1", section "3.5 Content Codings", see Content-Encoding: gzip