SOAP Client Perl Exmple

From Integrics Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use SOAP::Lite;

my $proxy = 'http://127.0.0.1/api/soap/';
my $username = 'soaptest';
my $password = 'soappw';

my $soap_client = SOAP::Lite->new(
    uri => 'Integrics/Enswitch/API',
    proxy => $proxy,
    on_fault => sub {
        goto &soap_error;
        }
    );
my @return_array = $soap_client->call( 'get_person', $username, $password, 0, 'findme@person.com' )->paramsall();
print Dumper $return_array[ 0 ];
exit 0;

sub soap_error {
    my ( $soap, $res ) = @_;

    if ( ref $res ) {
        die $res->faultstring();
    } else {
        die $soap->transport->status();
    }
}