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

Dear Monks,

What am I doing wrong here?

I was going through a very nice tutorial on SOAP::Lite at builder.com and everything was working
just fine up to their autodispatch example. Here's the example:
#!/usr/bun/perl -w use strict; #added by me cause perlmonks taught me so :) use SOAP::Lite +autodispatch => uri=>"World", proxy=>'http://soapserver.mycompany.com/soap/soapserver.cgi'; print HelloWorld(); print GoodByeWorld("sweet");
in case the problem is in the example perl object World
here is the code for that:
package World; sub new { bless {}, shift; }; sub HelloWorld { my ($self) = @_; return "Hello World\n"; }; sub GoodByeWorld { my ($self,$adjective) = @_; return "Goodbye $adjective World\n"; } 1;
Here's the output:
$ ./soapClientAutoDispatch.pl Use of inherited AUTOLOAD for non-method main::HellowWorld() is deprec +ated at ./soapClientAutoDispatch.pl line 7. Use of uninitialized value in string eq at /usr/lib/perl5/site_perl/5. +6.1/SOAP/Lite.pm line 2374. Use of uninitialized value in string eq at /usr/lib/perl5/site_perl/5. +6.1/SOAP/Lite.pm line 2374. Use of inherited AUTOLOAD for non-method main::GoodByeWorld() is depre +cated at ./soapClientAutoDispatch.pl line 8. Goodbye sweet World

I can only guess as to what the problem is.
Please help!

Replies are listed 'Best First'.
(jeffa) Re: SOAP autodispatch question
by jeffa (Bishop) on Apr 03, 2002 at 22:16 UTC
    Use of inherited AUTOLOAD for non-method main::HellowWorld() is ...
    
    Could this be a typo? Did you accidentally call method HellowWorld instead of HelloWorld? If you notice carefully, the message from GoodByeWorld was delivered. All of those warnings disturb me however ... but then again, i use mod_soap instead of autodispatch.

    UPDATE:
    Well, that didn't come out right ;). mod_soap is not a replacement for autodispatch, in fact, they can be used together. The problem is that autodispatch does some nasty UNIVERSAL::AUTOLOAD stuff. So, the solution to get rid of the warnings is to either not specify -w or use dispatch_from() instead:

    #!/usr/bin/perl -w use strict; use SOAP::Lite dispatch_from => 'World', uri => 'World', proxy => 'http://soapserver.mycompany.com/soap/soapserver.cgi' ; print World->HelloWorld(); print World->GoodByeWorld("sweet");
    I really prefer this style over autodispatch, but then again, i like my objects to have their own namespace. ;)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    

      This is indeed what I would consider the "best" approach under a "use strict" environment. I'm working on a book right now that uses SOAP::Lite a lot, and my approach has essentially been to document +autodispatch, then explain why it shouldn't be used for anything longer than 5-10 lines. I much prefer the clarity that dispatch_from maintains, particularly in that a person taking an initial glance at the source code is less likely to expect to find "HelloWorld" later in the script.

      And this is all before any issues of explicit data-encoding, namespace-association, or methods with characters not legal in Perl subroutine names, comes up :-).

      --rjray

      grrrr *headslap* A typo! Thanks man.
      And thanks for the adivce I'll look into mod_soap.