Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Basic authentication in SOAP

by mrguy123 (Hermit)
on Jul 20, 2006 at 12:39 UTC ( [id://562562]=perlquestion: print w/replies, xml ) Need Help??

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

Hi monks,
I am trying to retrieve a web page that uses basic authentication with the SOAP::Lite module. I have been able to retrive this page with the LWP::UserAgent, using this code to take care of authentication:
$header->authorization_basic($uname,$passwd);
$header is the name of the request header, which is then sent like this (with more info for the http transaction):
POST http://newscentre.aap.com.au/SRW/SRW.asmx Authorization: Basic dmljcGFybDJcbWV0YWxpYjo1bmV3c2NlbnRyZTM=
. I now want to do the same using SOAP::Lite. I read in the module documentation that SOAP::Lite supports basic authentication, but didn't find any other info about how to send the username and password. I can send info in the SOAP header, but I don't know how it can be done in the request header. Does anybody have any ideas?
Thanks, Guy
I think that I shall never see a billboard lovely as a tree.
Indeed, unless the billboards fall I'll never see a tree at all.
-- Ogden Nash

Replies are listed 'Best First'.
Re: Basic authentication in SOAP
by gellyfish (Monsignor) on Jul 20, 2006 at 12:46 UTC

    You should see the section entitled "HTTP BASIC AUTHENTICATION " in the SOAP::Transport documentation.

    Update: fixed the link [module://SOAP::Transport] seems to be broken.

    /J\

      Your link is broken, maybe this is correct SOAP::Transport.

      Solli Moreira Honorio
      Sao Paulo - Brazil
      Your link is leading to 'Not found' for me ... but this one here should point directly at the information you mention.

      -- Hofmator

      Thanks for your (very) quick reply. The section you referred me to contains this info
      BEGIN { sub SOAP::Transport::HTTP::Client::get_basic_credentials { return 'username' => 'password'; } }
      I still don't underdstand from this code how I can send the username and password as part of the SOAP request.

        Where it says 'username', put in the username to login as. Replace 'password' with the appropriate password for the username you're trying to use.

        SOAP::Transport will call this function to get the username and password to log in as, so when you override the function, it'll log in with what you tell it.

        You just have to include this code snippet (with username and password replaced of course) in your code using SOAP::Lite. That should do the trick according to the docs.

        Update: Ahrg, you guys are too quick for me :-) ... sorry for the double posts ...

        -- Hofmator

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-03-19 06:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found