Hammy has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I have a small piece of code that I wrote in a hosted environment (freeBSD) that works like a charm. I ported it as is over to a Red Hat Linux box and I get the following error - Can't call method "result" on an undefined value at 'myscript.pl' line 35. I have listed the code below including line 35 which begins with "$result=". Any suggestions you can offer would be greatly appreciated. One other bit of information, I had to add the XML::Simple and SOAP::Lite packages myself on the new box, but everything already existed on the old box. I only mention that because I wrote this well over a year ago so the versions are probably vastly different. Thanks.
use XML::Simple; use SOAP::Lite +trace; my $data = SOAP::Data->name('data' => "$xml")->type('string')->uri('') +; my $s = SOAP::Lite -> uri ('http://di.wellmed.com/SoapService') -> proxy ('https://di.webmdhealth.com/SoapService/SoapService.asmx') -> on_action(sub{join '/', @_}) -> on_fault(sub{}); $result = $s->PerformUpdate($data)->result;

Replies are listed 'Best First'.
Re: Error running SOAP statement
by mda2 (Hermit) on Feb 23, 2006 at 03:58 UTC
    Your code donīt especify content for $xml, and Iīm supose this is a error cause... (changed proxy to use http transport).

    --
    Marco Antonio
    Rio-PM

      Sorry, I left off one line. The $xml variable is passed in as a well formed XML stream. I will look at the difference between proxy and transport, but I am confused why it would work like a charm in one environment and not in the other. Any idea what that error message is telling me?
        Use a normal fault on result...
        use SOAP::Lite +trace; my $data = SOAP::Data->name('data' => "$xml")->type('string')->uri('') +; my $s = SOAP::Lite -> uri ('http://di.wellmed.com/SoapService') -> proxy ('http://di.webmdhealth.com/SoapService/SoapService.asmx') # -> on_fault(sub{}); ; $result = $s->PerformUpdate($data); unless ( $result && ref($result) ) { print "Empty on result!\n"; } elsif ( $result->fault ) { print "FAULT: ", $result->faultcode, " ", $result->faultstring, "\n +\n"; } else { print $result->result; }
        This page return incorrect encoding...
        Unexpected Content-Type 'text/html; charset=Windows-1252' returned

        --
        Marco Antonio
        Rio-PM