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.
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) |
#!\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; |