#!/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"; } #### bear 2 toybox brown large car 2 shelf red small Sorry 1 toybox Chess 4 shelf none medium #### $VAR1 = { 'Toys' => bless( { 'Toy' => [ bless( { 'ToyLocations' => bless( { 'ToyLocation' => { 'toyName' => 'bear', 'toyQuantity' => '2', 'locationName' => 'toybox' } }, 'ArrayOfToyLocation' ), 'color' => 'brown', 'size' => 'large' }, 'Stuffed' ), bless( { 'ToyLocations' => bless( { 'ToyLocation' => { 'toyName' => 'car', 'toyQuantity' => '2', 'locationName' => 'shelf' } }, 'ArrayOfToyLocation' ), 'color' => 'red', 'size' => 'small' }, 'Electric' ), bless( { 'ToyLocations' => bless( { 'ToyLocation' => [ { 'toyName' => 'Sorry', 'toyQuantity' => '1', 'locationName' => 'toybox' }, { 'toyName' => 'Chess', 'toyQuantity' => '4', 'locationName' => 'shelf' } ] }, 'ArrayOfToyLocation' ), 'color' => 'none', 'size' => 'medium' }, 'Board' ) ] }, 'ArrayOfToy' ) }; #### foreach my $e (@{$getToysResults->{Toys}{Toy}}){ foreach my $f (@{$e->{ToyLocations}{ToyLocation}}){ ...