Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
PERL
#/usr/bin/perl -w
use strict;
open FILE1,"+>>log.txt" or die $1;
# remove the +trace => all to remove extensive output HTTP/SOAP traces
use SOAP::Lite +trace => 'all';
#use MIME::Entity;

# instantiate a soap client object
my $soap = SOAP::Lite
	-> uri('https://ws3.sticomputer.com/LabVendorWeb/LabVendor.asmx')
	-> on_action( sub { '"'.join('/', 'http://sticomputer.com/lab', $_[1]).'"' } )
	-> proxy('https://ws3.sticomputer.com/LabVendorWeb/LabVendor.asmx');

# call the Ping() method
print "Calling Ping...\n";
print $soap->Ping()->result;
print "done.\n";

# call the HelpAbout() method
print "Calling HelpAbout...\n";
my $result = $soap->HelpAbout();
print $result->valueof('//HelpAboutResult' )."\n";
print "done.\n";

my @files = <*.hl7>;
foreach my $file (@files){
	print "Calling PutFile....\n";

	my $method = SOAP::Data->name('PutFile')
		->attr({xmlns => 'http://sticomputer.com/lab'});

	my $fileContents = "";
	open( LABFILE,"<$file" );
	while( <LABFILE> ) {
		$fileContents .= $_;
	};
	close ( LABFILE);

	my @params = (
		SOAP::Data->name('vendorID' => 'xxxx'),
		SOAP::Data->name('vendorPassword' => 'xxxx'),
		SOAP::Data->name('fileData' => $fileContents)
		);

	my $return = $soap->call($method => @params)->result;
	<big><code>die $return->faultstring if ($return->fault);</code></big>
	print $return->result, "\n";
}
print "done.\n";

The error message is: Can't call method "fault" on an undefined value at D:\Perl\test.pl line 46.
I have seen this code in a number to books and websites so please let me know how to fix this.

Thank you
Steven Andler
Posted
Updated 19-May-11 5:13am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900