#/**************** Settings begin **************/
my $username  = ''; # Enter your Interfax username here
my $password  = ''; # Enter your Interfax password here
my $transactionID = "";
my $NS = 'http://www.interfax.cc';
#/**************** Settings end ****************/
 
 
my $client = SOAP::Lite
	->uri($NS)
	->on_action( sub { join '/', $NS, $_[1] } ) 
	->proxy('https://ws.interfax.net/dfs.asmx?WSDL');
 
my $result = $client
	->call(SOAP::Data->name('GetFaxImage')->attr({xmlns => $NS}) =>
			SOAP::Data->name('Username')->value($username)->type(''),
		    SOAP::Data->name('Password')->value($password)->type(''),
		    SOAP::Data->name('TransactionID')->value($transactionID)->type('')
	);
 
 
if ( $result->fault ) {
    print $result->faultstring . "\n";
} else {
	if( $result->valueof('//GetFaxImageResult') == 0 ) {
		#  Write the received image to a tif file with the same name as the transaction ID
		open (FILE, ">>$transactionID.tif");
		print FILE decode_base64($result->valueof('//GetFaxImageResponse/Image'));
		close (FILE);
 
		print "Success" . "\n";
	} else {
		print "Error, return code=" . $result->valueof('//GetFaxImageResult') . "\n";
	}
}