[Back]

Calling the WoRMS webservice from Perl

Step 1: Install Perl
Go to http://www.perl.org, download & install Perl (Windows/Mac OS X/Linux).

Step 2: Install the SOAP::Lite (with the CPAN shell)
>perl -MCPAN -e shell
cpan> install SOAP::Lite

Step 3: Copy/paste the following code in a file 'Aphia_webservice_Perl.pl'

use SOAP::Lite;

my $endpoint = qq{https://www.marinespecies.org/aphia.php?p=soap} ;
my $tns = 'http://aphia/v1.0' ;

my $method_urn = $tns ;
my $soapaction = $tns ;

my $sObj = SOAP::Lite->new(uri => $soapaction, proxy => $endpoint) ;

my $response = $sObj->call(SOAP::Data->name('getAphiaID')->attr({ 'xmlns' => $method_urn})
            => SOAP::Data->name('ScientificName' => 'Solea solea')) ;

print $response->result, "\n";

Step 4: Run the script from the command line
>perl -f Aphia_webservice_Perl.pl

#this should output '127160'

Download this example.