in reply to Sending HTTP credentials with SOAP

Does wsdl2perl.pl help?
{ # a block just to scope "no warnings" no warnings qw(redefine); *LWP::UserAgent::get_basic_credentials = sub { my ($user, $password); # remove user from option if called, to force prompting for a +user # name the next time print "URL requires authorization.\n"; if (not $user = delete $opt{user}) { print 'User name:'; ReadMode 1; $user = ReadLine(); ReadMode 0; chomp $user; }; if (not $password = delete $opt{password}) { print 'Password:'; ReadMode 2; $password = ReadLine; ReadMode 0; chomp $password; }; return ($user, $password); }; }

Replies are listed 'Best First'.
Re^2: Sending HTTP credentials with SOAP
by Corion (Patriarch) on Mar 17, 2010 at 08:42 UTC

    While monkeypatching LWP works, I prefer to derive a class from LWP::UserAgent that implements get_basic_credentials so it's possible to have connections to more than one server and to avoid interference with other modules using LWP::UserAgent.

      That is generally the way to do things, but author of wsdl2perl.pl is author of SOAP::WSDL, and my guess is he might know something we don't.
      Unfortunately, I don't think that helps me. The SOAP library would still call LWP, not my derived class.
Re^2: Sending HTTP credentials with SOAP
by astroboy (Chaplain) on Mar 17, 2010 at 19:46 UTC
    wsdl2perl.pl is what I used to generate the classes. I think the code you quoted is to read a WSDL file that is protected. Anyway, it would still have the same problem, since the code I quoted in the OP does pretty much the same thing ... providing a method to get called when challenged for authentication details (since LWP is used under the covers anyway). If LWP doesn't get a 401 HTTP response code, it won't send the authentication details