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:

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.

Set shell to PERL interpreter (UNIX specific)

 #!\bin\Perl\bin\perl -w

 

 

Include compression library into execution unit

use Compress::Zlib;

 

use SOAP::Lite +trace => 'debug';

 

 

Set name space to the SOAP  service you are calling

$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

  -> uri($namespace)                       

  -> on_action(sub{sprintf '%s/%s', @_ })

  -> outputxml("1")

Set a low compression threshold for request (to prevent gzip compression on the request, set threshold to 1000000)

  -> proxy($endpoint, options => {compress_threshold => 1});

 

 

 

sub SOAP::Transport::HTTP::Client::get_basic_credentials {

 

    return $username => $password;

 

  }

 

 

Set request parameters

$request = '

<Request>

            <LocalDateTimeCT_6_0 xmlns="">

                        <LocalDateTimeMods>

                                    <ReqCity>ORD</ReqCity>

                        </LocalDateTimeMods>

            </LocalDateTimeCT_6_0>

</Request>';

 

$filter = '

<Filter>

            <_ xmlns="" />

</Filter>';

 

 

Invoke SOAP call

my $response = $soap

  ->call(SOAP::Data->name($action)->attr({xmlns => $namespace}),

         SOAP::Data->name(Profile => $ hostaccessprofile)->type('string'),

         SOAP::Data->name(Request => $request)->type('xml'),

         SOAP::Data->name(Filter => $filter)->type('xml'));

 

 

 

print $response;