in reply to Re: Basic authentication in SOAP
in thread Basic authentication in SOAP

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.

Replies are listed 'Best First'.
Re^3: Basic authentication in SOAP
by jhourcle (Prior) on Jul 20, 2006 at 13:01 UTC

    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.

      Thanks. I have done what you said. However, I would expect to see something like this in the header when I send my request:
      POST http://newscentre.aap.com.au/SRW/SRW.asmx Authorization: Basic dmljcGFybDJcbWV0YWxpYjo1bmV3c2NlbnRyZTM=
      . Since this is not in the header (or anywher else in the SOAP request), I think that I am missing something. Are you sure this is all that needs to be done?

        You'd think so, but you'd be wrong -- HTTP basic authentication is normally a two pass process -- once for the client to find it needs authentication, and a second request when it actually sends the authentication. In HTTP, a server might have multiple realms associated with it, and the client has no way of knowing which realm it needs to authenticate under without the first failed connection.

        See F5 for a work around if you want it to only do one pass. (it also shows directly messing with $soap->transport(), which gives you access to the SOAP::Transport object.)

      I see that I have been down voted twice by now (first time ever), and it probably looks like I want others to do the work for me. I think I should mention that I have been spending a lot of hours in the past few days trying to understand the SOAP::Lite module, which compared to other modules I worked with in the past is not that user friendly (a much longer discussion about this issue can be found here). I'm sorry if the questions aren't that great, but please be patient. Thanks for the help,
      Guy
Re^3: Basic authentication in SOAP
by Hofmator (Curate) on Jul 20, 2006 at 13:02 UTC
    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