#!/usr/bin/perl # use SOAP::Lite; use Data::Dumper; # Load server CA certificate # $ENV{HTTPS_CA_FILE} = "ca.cer"; my $soap = SOAP::Lite->new(proxy => 'https://webserver:443/ToyService/ToyWebService'); $soap->readable(1); # Setup credentials # sub SOAP::Transport::HTTP::Client::get_basic_credentials { return 'user' => 'pass'; # Execute SOAP Request # sub doSOAPCall { my $method = $_[0]; eval { my $res = $soap->call($method)->result; return $res; 1; } or die; } # Build method and parameters for GetToys and execute call to web service # my $getFrobMethod = SOAP::Data->name('getToys') ->attr({xmlns => 'web.service.namespace'}); my $getToysResults = &doSOAPCall($getToysMethod); # Print output for TOYS # foreach my $e (@{$getToysResults->{Toys}{Toy}}){ print "$e->{color}\n"; if ($e->{ToyLocations}{ToyLocation}{locationName}){ $location = $e->{ToyLocations}{ToyLocation}{locationName}; $location = "XXX$location"; } else { $location = "XXX"; } print "TOYS\/$e->{color}\/$e->{ToyLocations}{ToyLocation}{toyName}\/$e->{ToyLocations}{ToyLocation}{toyQuantity}\/$location\/\n"; }