Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

by Plankton (Vicar)
on Apr 10, 2011 at 23:37 UTC ( [id://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

Replies are listed 'Best First'.
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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-23 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found