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

Hey Everyone ... so I'm trying to use SOAP::Lite, pretty new to it, and I'm having a problem. In the code below I'm trying to pass a variable to the 'proxy' parameter of SOAP::Lite, however when I use a variable I get "proxy: transport protocol not specified", if I use a hardcoded value instead of the variable it works correctly. Anyone have any ideas?
my $soap_url = 'http://www.someotheraddress/soap'; use SOAP::Lite +autodispatch => uri => 'http://www.someaddress/something' , proxy => $soap_url , on_fault => sub { my ( $soap, $res ) = @_; die ref $res ? "FAULT: " . $res->faultstring : "FAULT: " . $soap->transport->status, "\n" } ;
Output:
proxy: transport protocol not specified BEGIN failed--compilation aborted at ./TEST2.pl line 33.

Replies are listed 'Best First'.
Re: Issues trying to pass variable to SOAP::Lite
by pc88mxer (Vicar) on Apr 29, 2008 at 18:33 UTC
    That's because use SOAP::Lite takes place at compile time which is before the assignment to $soap_url is made. You can get around this by setting $soap_url in a BEGIN block:
    BEGIN { our $soap_url = "..." }; use SOAP::Lite ..., proxy => $soap_url, ...;
    Note that you can't declare $soap_url using my.
      Thanks for the info ... that makes sense, however I'm running this in a persistent perl environment, don't know if the begin block will work in my case, I'll try. Any other ideas while I'm giving it a shot? Thanks Again.
      So the begin block worked as mentioned, however it did break my script when placed in a persistent environment, since the begin block is only activated once in this environment. So ... anyone else have some ideas? If autodispatch is broken, is there a way around this?
        perldoc -f use
        perldoc -f import
Re: Issues trying to pass variable to SOAP::Lite
by kyle (Abbot) on Apr 29, 2008 at 18:38 UTC

    According to the SOAP::Lite documentation, +autodispatch doesn't work in Perl 5.8. I wonder if that has something to do with it.