Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

SOAP::Lite authentication

by rahed (Scribe)
on Dec 19, 2007 at 14:01 UTC ( [id://657873]=perlquestion: print w/replies, xml ) Need Help??

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

I call a web service by means of a SOAP::Lite client.
The service requires authentication.
Defining the usr/password in the proxy parameter like this works:

'proxy' =>('http://user:password@url/web/service')
The docs say I can rewrite the get_basic_credentials method like this:
sub SOAP::Transport::HTTP::Client::get_basic_credentials { return 'user' => 'password'; }
But this doesn't work, there's no http header authentication.

I konw the method is defined in LWP::UserAgent module but have no idea where it's called from SOAP::Lite.

Any suggestions?

Replies are listed 'Best First'.
Re: SOAP::Lite authentication
by roman (Monk) on Dec 19, 2007 at 17:02 UTC

    I am not an authentication expert, but are you sure you use basic authentication?

    In my environment both methods (user info in URI, get_basic_credentials) work for an Apache with basic authentication, but only the first one succeed with IIS6.0 using NTLM authentication.

      The service is implemented with a WebLogic server. I think it's basic authentication.
Re: SOAP::Lite authentication
by rahed (Scribe) on Dec 27, 2007 at 15:08 UTC
    I wanted to avoid defining credentials in a proxy parameter and so investigated further.

    I think the server rejects the connection and doesn't ask for the credentials again. The get_basic_credentials method is probably called as later as in this moment.

    So I added an Authorization header this way:
    $authoriz = 'Basic '.encode_base64('user:passwd'); $soap->transport->http_request->headers->push_header('Authorization'=> +$authoriz);
    encode_base64 is a function from MIME::Base64 module.
    And this way it's ok now.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-03-19 05:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found