robert.heise has asked for the wisdom of the Perl Monks concerning the following question:

Im trying to create a SOAP::Lite client using SOAP::Lite. However i cant seem to get the syntax correctly. I need to create a server connection dynamically so I have to construct the proxy and uri parameters with an inpute variable. However, when i do that it either doesnt accept my variable or im getting a '' host INET error.

my $uri = "tcp://$server/ENG/AddressManagement/NameServerManagement"; my $proxy = 'tcp://rheise-linux:82'; my $result; eval { use SOAP::Lite +autodispatch => uri => $uri, proxy => 'tcp://rheise-linux:82', on_fault => sub { my( $soap, $res ) = @_; confess (ref $res ? $res->faultstring : ($soap->transp +ort->status, "\n")); };

When I substitute proxy => with proxy => $proxy I get the error message: proxy: transport protocol not specified

Anybody work with SOAP::Lite and passing in dynamic parameters verse strings?

thanks

2006-11-11 Retitled by g0n, as per Monastery guidelines
Original title: 'SOAP::Lite'

Replies are listed 'Best First'.
Re: Problems creating a SOAP::Lite client
by Tanktalus (Canon) on Nov 10, 2006 at 19:34 UTC

    First off, please close your <code> tag.

    Next, you're missing the implicit BEGIN there. Remember that use is a require and import inside a BEGIN block. What that means is that your use line is executing outside the eval, and before $proxy is initialised. Putting your initialisation inside another BEGIN block would work.

    my ($uri, $proxy, $result); BEGIN { $uri = "tcp://$server/ENG/AddressManagement/NameServerManagement"; $proxy = 'tcp://rheise-linux:82'; } use SOAP::Lite ...;
    Hope that helps,

      Thanks for your ideas. The problem is that I need to dynamically create both the proxyURI and the bindingURI as this application will hit multiple servers. I dont think using BEGIN will work since I need the uri and proxy fields to support multiple connection points during the runtime of the script itself. Is there a way to use autodispatch and not use  use SOAP::Lite ? This way I could create a SOAP::Lite object in main, and recall that object over the lifecycle of the script passing in different proxy and bind paths? Thanks Rob

        Why do you need autodispatch? There appears to be a tradeoff here. On one hand is autodispatch for when you have the proxy info at compile time. On the other is the regular dispatch where you can specify all that exactly where you need it, but can do so dynamically.

        It appears that you want your cake and you want to eat it, too. From a cursory glance at the SOAP::Lite docs, it does not appear that SOAP::Lite allows for that.

        That said, you might be able to do your own imports...

        use SOAP::Lite; SOAP::Lite->import(autodispatch => uri => $uri, proxy => $proxy, # etc... );
        That might work - hopefully there aren't any functions with prototypes in there ... although I have to admit that I doubt that to be the case. There may be other gotchas, too, I'm not sure.