Dirk Bergmann

Developer, panographer. Does consultancy work from own company. Lives in Chiang Mai, Thailand.

Twitter

Chiang Mai

Hua Hin

Thailand Hotels

ListVote - List. Vote. Learn.

Partnerseek - Find Partners

Enabling gzip Compression with SOAP4R

It's a one-liner, but info isn't easy to find (as usual with soap4r).

When you generate your local driver with for example

wsdl2ruby.rb --wsdl MyService.wsdl --classdef MyService --type client --force

and you instantiate your proxy driver like so

ms = MyService.new  
ms.wiredump_dev = STDERR

you simply add

ms.streamhandler.accept_encoding_gzip = true

That's all. No need for custom headers etc.

And: zlib (compression library used by soap4r) is built into Ruby since version 1.8. No need for any gems or other shenenigans.

##

As an added year-end bonus, here's a list of links that helped me with SOAP and ruby over the years:

Excellent SAP article:

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/505ac48e-0578-2a10-60be-c5ffe14a0134

Correct usage of wsdl2ruby (must be wsdl2ruby.rb)

http://www.hostingrails.com/236/Using-Web-Services-Description-Language-wsdl2ruby-and-soap4r-as-a-clientI

ActionWebService:

http://www.datanoise.com/articles/2008/7/2/actionwebservice-is-back

Links:

http://www.brendonwilson.com/blog/2006/04/02/ruby-soap4r-wsdl-hell/

WSDL/Ruby:

http://codeidol.com/other/rubyckbk/Web-Services-and-Distributed-Programming/Using-a-WSDL-File-to-Make-SOAP-Calls-Easier/

Very Helpful Detailed Article:

http://www.ibm.com/developerworks/opensource/library/os-ws-rubyrails/index.html

xsltproc examples:

http://linux.byexamples.com/archives/463/xslt-processor-command-line/

xsd2wsdl:

http://jira.springframework.org/secure/attachment/12306/XsdToWsdl.xsl

linked from here:

http://jira.springframework.org/browse/SWS-79

Don’t forget to enable wiredump:

fe.wiredump_dev = STDERR

Get rid of NS1:

http://www.pluitsolutions.com/2007/08/10/remove-n1-namespace-for-soap4r/