gzip compression for Perl/SOAPLite
To enable the HTTP header request to encode the request and response for gzip compression on a Perl system, and to accept gzip compression in the response:
-
Install SOAPLite Perl module version 0.6 or later. See http://www.soaplite.com.
-
Install the Compress::Zlib module.
See the section on enabling compression at http://cookbook.soaplite.com for more instructions.
Modifying Perl Code
The GWS Server will respond with a gzip compressed message only if the client can accept gzip compression, which is indicated by client sending an Accept-Encoding header with a 'gzip' value.
-
The SOAP::Lite client will send the header 'Accept-Encoding' with value 'gzip' if:
-
The threshold is specified.
-
The module Compress::Zlib is available on the client machine.
-
If the size of the SOAP::Lite client’s current request message exceeds the threshold specified, then the current request message will be gzip compressed before it is sent.
-
For un-annotated code, see the gzip Perl/SOAPLite Sample 1 topic.
Set shell to PERL interpreter (UNIX specific) |
|
|
|
Include compression library into execution unit |
use Compress::Zlib; |
|
use SOAP::Lite +trace => 'debug'; |
|
|
Set
name space to the SOAP |
$namespace = 'http://webservices.galileo.com'; |
Set endpoint to the URL where the SOAP service is available (either copy or production). Ensure you set URL appropriate to service level or region. |
$endpoint = 'https://americas.webservices.travelport.com/B2BGateway/service/XMLSelect'; |
Set action to the appropriate SOAP action |
$action = 'SubmitXml'; |
|
|
|
$hostaccessprofile = 'DynApolloCopy_XXX'; |
Set user credentials |
$username = 'XXXXXXXXXX'; |
$password = 'XXXXXXX'; |
|
|
|
Create SOAP call |
my $soap = SOAP::Lite |
|
|
|
|
|
|
Set a low compression threshold for request (to prevent gzip compression on the request, set threshold to 1000000) |
|
|
|
|
sub SOAP::Transport::HTTP::Client::get_basic_credentials { |
|
|
|
|
|
|
Set request parameters |
$request = ' |
<Request> |
|
|
|
|
|
|
|
|
|
|
|
</Request>'; |
|
|
|
$filter = ' |
|
<Filter> |
|
|
|
</Filter>'; |
|
|
|
Invoke SOAP call |
my $response = $soap |
|
|
|
|
|
|
|
|
|
|
|
print $response; |