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

Hello i try to use sooap::lite but il have many problems... here is my code :
#!/usr/bin/perl use SOAP::Lite; $tab = SOAP::Lite -> service('http://url.wsdl','login'=> $login,'password +'=> $passwd,'exception s'=>'1'); print "$tab\n"; foreach my $info (@{$tab}) { print "$info\n"; }
but i get this :
Can't call method "new" on an undefined value at /usr/share/perl5/SOAP +/Lite.pm line 3364.
i have an example in php and it's work's but i would like to do that in perl... someone can help me? thanks...

Replies are listed 'Best First'.
Re: pb with Soap::lite
by olus (Curate) on Feb 20, 2008 at 19:05 UTC

    You should start by creating the service object and then call the methods you want, and that are available on the contract (WSDL). In your example you are not showing what method you are calling.

    #!/usr/bin/perl use strict; use warnings; use SOAP::Lite; my $service = SOAP::Lite -> service('http://url.wsdl'); # now call the login (?) method on the remote service # I am assuming the method you are attempting is Login my $tab = $service->call('Login' => @params_to_login);

    As a suggestion, turn on debugging mode (use SOAP::Lite +trace => qw(method trace debug);) so that you can see the messages that are being passed between your client and the service, and also use Data::Dumper to explore the results you get from the method calls.

      sorry i forgot a piece of code... here it is :
      #!/usr/bin/perl use SOAP::Lite +trace; $login='log'; $passwd='pass'; $domain='dom' $tab = SOAP::Lite -> service('http://url.wsdl','login'=>$login,'password'=> $pass +wd,'exceptions'=>'1') ->getDomUsedQuota($domain); print "$tab\n";
      And herre is the php code... if it can help you (me not)
      <? $login='votre_login'; $passwd='votre_mot_de_passe'; $domain='votre_domaine'; <code> $client = new SoapClient('https://url.wsdl',array('login'=> $login,'pa +ssword'=> $passwd,'exceptions'=>'1')); $used_quota=$client->getDomUsedQuota($domain); print "Le quota consommé est $used_quota <br>"; ?>
      I try "+trace", but it doesn't help me... i'm too novice in perl and soap... ;-) Thanks in advance

        If you try to access the service using basic authentication, then you might try adding the code below to provide the auth info when requested.

        ... sub SOAP::Transport::HTTP::Client::get_basic_credentials { return 'username' => 'password'; } my $service = SOAP::Lite -> service('http://url.wsdl'); ...