feiiiiiiiiiii has asked for the wisdom of the Perl Monks concerning the following question:
Hi guys,
I'd like to create a SOAP client and connect to the soap web service. However, I'm having trouble getting through the authentication. Here is what it does through the web browser. The Perl login process will be a simulation of this.
1, Enter the WSDL address into the web browser
2, It will redirect me to the login url3, I enter the username and password
4, Login succeeds. It redirects me to the original WSDL url and show the content.
5, Once I've logged in, the cookie will be carried in all subsequent requests. So I won't be challenged to login again
I believe the key points to handle this in Perl is:
1, Handle the redirection of HTTP requests
2, The protocol is HTTPS. Maybe there's some special handling of SSL?
3, Handle the basic authentication
4, Handle the cookie
I tried the code as below:
my $wsdl_url = 'https://xyz.com/download?wsdl'; my $url = 'https://xyz.com/download'; my $user = 'abc'; my $password = '123'; SOAP::Transport::HTTP::Client::get_basic_credentials = sub { return ($user, $password); }; my $client= SOAP::Lite -> service($wsdl_url); my $cookie_jar = HTTP::Cookies->new(); $client->proxy($url, cookie_jar => $cookie_jar, );
If I try to call a method of the client, all I get is fault message or 401 not authorized error. What is the standard code for implementing this?
Thank you so much!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SOAP authentication
by Corion (Patriarch) on May 28, 2016 at 16:01 UTC |