Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Help with using SOAP::Transport::HTTP::Client::get_basic_credentials

by Plankton (Priest)
on Apr 10, 2011 at 23:37 UTC ( #898636=perlquestion: print w/ replies, xml ) Need Help??
Plankton has asked for the wisdom of the Perl Monks concerning the following question:

Dear Wise Monks When I execute
# setup the HTTP Basic Auth parameters BEGIN { sub SOAP::Transport::HTTP::Client::get_basic_credentials { ret +urn $user => $pass; }}
in one sub routine it works fine and I can authenticate against the web service, but if I execute ...
# setup the HTTP Basic Auth parameters BEGIN { sub SOAP::Transport::HTTP::Client::get_basic_credentials { ret +urn $user => $pass; }}
... in any other sub routine I get these error:
my.pm [579] Fault ... syntax error at line 1, column 49, byte 49 at ... i686-linux/XML/Parse +r.pm line 185 Authorization Required This server could not verify that you are authorized to access the doc +ument requested. Either you supplied the wrong credentials (e.g., bad + password), or your browser doesn't understand how to supply the cred +entials required.
.. what am I doing wrong? Thanks

Comment on Help with using SOAP::Transport::HTTP::Client::get_basic_credentials
Select or Download Code
Re: Help with using SOAP::Transport::HTTP::Client::get_basic_credentials
by Khen1950fx (Canon) on Apr 11, 2011 at 01:06 UTC
    I'd add the user and the password to the proxy and add a fault callback:
    #!/usr/bin/perl use strict; use warnings; use SOAP::Lite +trace => [ fault => \&log_faults ]; use SOAP::Transport::HTTP::Client; my $user = 'user'; my $pass = 'pass'; use SOAP::Lite +autodispatch => uri => 'http://www.soaplite.com/My/Examples', proxy => 'http://$user:$pass@localhost/', on_fault => sub { my($soap, $res) = @_; die ref $res ? $res->faultdetail : $soap->transport->status, +"\n"; }; sub SOAP::Transport::HTTP::Client::get_basic_credentials { return $user => $pass; } sub log_faults { open LOGFILE, '>', '/root/Desktop/fault.log'; print LOGFILE $_[0] . "\n"; close LOGFILE; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://898636]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2014-09-21 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (166 votes), past polls