Loading ...
Sorry, an error occurred while loading the content.
 

Re: [soaplite] Basic Authentication with SOAP::Lite?

Expand Messages
  • Byrne Reese
    You will need to wrap your authentication code in a BEGIN block... like so: BEGIN { sub SOAP::Transport::HTTP::Client::get_basic_credentials { return
    Message 1 of 4 , Aug 24, 2003
      You will need to wrap your authentication code in a BEGIN block... like so:

      BEGIN {
      sub SOAP::Transport::HTTP::Client::get_basic_credentials {
      return 'username' => 'password';
      }
      }

      >
      >
      >
      >
      > Hi,
      >
      > I'm getting an error when I'm trying to use the
      > Authentication Basic in SOAP::Lite.
      > I'm using a Soap::Lite based Perl client accessing
      > Apache Axis based on java service.
      > I verified if the LWP::Authen::Basic module is well
      > installed as well as other modules.
      > I read the http://guide.soaplite.com/ and I tried to
      > use all the techniques mentioned in the guide to pass
      > the user and password, they don't seem to work!
      > Looking at the code, nothing seems to be implemented!
      >
      > Here's a part of my perl client code:
      >
      > #! /usr/bin/perl -w
      >
      > use Data::Dumper;
      > use Env;
      > use SOAP::Lite +trace =
      > on_fault =
      > eval { die ref $res ?
      > $res-
      > $soap-
      > return ref $res ? $res : new
      > SOAP::SOM;
      > };
      >
      > $HOST="http://quadri:4043/xxxxxxx/HelloIF";
      > $NS="urn:x-netcelo:xxxxxxxxx.HelloIF";
      > $PHRASE=shift;
      >
      > my $soap= SOAP::Lite
      > -
      > -
      > -
      >
      > sub
      > SOAP::Transport::HTTP::Client::get_basic_credentials {
      > return 'username' =
      > }
      >
      > my $som=$soap
      > -
      > print "The response from the server was: \n"
      > .$som-
      > 1;
      >
      > Here is a trace fragment for the call from perl
      > client: (I used Dumper method in the method
      > "send_receive" from /SOAP/Transport/HTTP.pm to dump
      > the $req (an instance from the HTTP::Request class) )
      >
      >
      > bless( {
      > '_method' =
      > '_headers' =
      > 'soapaction'
      > =
      > '"urn:x-netcelo:webServices.HelloIF#sayHello"',
      >
      > 'content-type'
      > =
      > charset=utf-8',
      >
      > 'content-length' =
      > 'accept' =
      >
      > 'text/xml',
      >
      > 'multipart/*'
      > ]
      > },
      > 'HTTP::Headers' ),
      > '_uri' =
      > 'http://quadri:4043/wservices/HelloIF')},
      > 'URI::http' ),
      > '_content' =;?xml version="1.0"
      > encoding="UTF-8"?
      >>;SOAP-ENV:Envelope
      > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      > xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      > xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      >
      > >;SOAP-ENV:Body
      > >;namesp1:sayHello
      > xmlns:namesp1="urn:x-netcelo:webServices.HelloIF"
      > >;c-gensym4 xsi:type="xsd:string"
      >
      > ;/c-gensym4;/namesp1:sayHello;/SOAP-ENV:Body;/SOAP-ENV:Envelope
      >
      > }, 'HTTP::Request' );
      >
      > If we modify SOAP/Transport/HTTP.pm (send_recieve) we
      > can explicitly add the basic_authentication header.
      > However we have found no correct way of passing the
      > authentication parameters with the standard SOAP::Lite
      > interface. The "proxy" method accepts parameters that
      > are methods from LWP::UserAgent, but they are
      > not used....
      >
      > What am I missing?
      > Thanks for your help..
      >
      > Best regards,
      > Lina
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > Yahoo! Groups Sponsor
      >
      >
      > ADVERTISEMENT
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > To unsubscribe from this group, send an email to:
      > soaplite-unsubscribe@yahoogroups.com
      >
      >
      >
      >
      >
      > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
      >
      >
      >
      >
      >


      ^byrne :/
    • Lina Alshaal
      Thanks a lot Byrne, your are definitely right. I tested the code with another server, and it works pretty good. I found that the problem which i met came from
      Message 2 of 4 , Aug 26, 2003
        Thanks a lot Byrne,

        your are definitely right. I tested the code with another server, and it works pretty good.
        I found that the problem which i met came from the Apache Axis server itself.

        when the client program sent a SOAP message to the server, it sent it without any authentication parameters in the HTTP header. If the server requires such kind of information,  it sends back a '401 Unauthorized' message, thus the client sends back another HTTP message with the
        authentication parameters.

        In the Apache Axis, the server gets the client message without the authentication parameters and sends back a '500 Internal Server Error' !! it might be a misconfiguration from us!! Is there any way to force SOAP::Lite to send the authentication info in the first message without modifying the code?

        Thanks for any pointers!
        Best regards,
        lina
         

        Byrne Reese wrote:

        You will need to wrap your authentication code in a BEGIN block... like so:

        BEGIN {
          sub SOAP::Transport::HTTP::Client::get_basic_credentials {
            return 'username' => 'password';
          }
        }

        >
        >
        >
        >
        > Hi,
        >
        > I'm getting an error when I'm trying to use the
        > Authentication Basic in SOAP::Lite.
        > I'm using a Soap::Lite based Perl client accessing
        > Apache Axis based on java service.
        > I verified if the LWP::Authen::Basic module is well
        > installed as well as other modules.
        > I read the http://guide.soaplite.com/ and I tried to
        > use all the techniques mentioned in the guide to pass
        > the user and password, they don't seem to work!
        > Looking at the code, nothing seems to be implemented!
        >
        > Here's a part of my perl client code:
        >
        > #! /usr/bin/perl -w
        >
        > use Data::Dumper;
        > use Env;
        > use SOAP::Lite +trace =
        >         on_fault =
        >                 eval { die ref $res ?
        > $res-
        > $soap-
        >                 return ref $res ? $res : new
        > SOAP::SOM;
        >         };
        >
        > $HOST="http://quadri:4043/xxxxxxx/HelloIF";
        > $NS="urn:x-netcelo:xxxxxxxxx.HelloIF";
        > $PHRASE=shift;
        >
        > my $soap= SOAP::Lite
        >         -
        >         -
        >         -
        >
        > sub
        > SOAP::Transport::HTTP::Client::get_basic_credentials {
        >   return 'username' =
        >        }
        >
        > my $som=$soap
        >         -
        > print "The response from the server was: \n"
        > .$som-
        > 1;
        >
        > Here is  a  trace fragment for the call from perl
        > client:  (I used Dumper method in the method
        > "send_receive" from /SOAP/Transport/HTTP.pm to dump
        > the $req (an instance from the  HTTP::Request class) )
        >
        >
        >  bless( {
        >                  '_method' =
        >                  '_headers' =
        >                                         'soapaction'
        > =
        > '"urn:x-netcelo:webServices.HelloIF#sayHello"',
        >
        >                                         'content-type'
        > =
        > charset=utf-8',
        >
        > 'content-length' =
        >                                         'accept' =
        >
        > 'text/xml',
        >
        > 'multipart/*'
        >                                                     ]
        >                                       },
        > 'HTTP::Headers' ),
        >                  '_uri' =
        > 'http://quadri:4043/wservices/HelloIF')},
        > 'URI::http' ),
        >                  '_content' =;?xml version="1.0"
        > encoding="UTF-8"?
        >>;SOAP-ENV:Envelope
        > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        > xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        > xmlns:xsd="http://www.w3.org/1999/XMLSchema"
        >
        >   >;SOAP-ENV:Body
        >     >;namesp1:sayHello
        > xmlns:namesp1="urn:x-netcelo:webServices.HelloIF"
        >       >;c-gensym4 xsi:type="xsd:string"
        >
        > ;/c-gensym4;/namesp1:sayHello;/SOAP-ENV:Body;/SOAP-ENV:Envelope
        >
        >                }, 'HTTP::Request' );
        >
        > If we modify SOAP/Transport/HTTP.pm (send_recieve) we
        > can explicitly add the basic_authentication header.
        > However we have found no correct way of passing the
        > authentication parameters with the standard SOAP::Lite
        > interface. The "proxy" method accepts parameters that
        > are methods from LWP::UserAgent, but they are
        > not used....
        >
        > What am I missing?
        > Thanks for your help..
        >
        > Best regards,
        > Lina
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > Yahoo! Groups Sponsor
        >
        >
        >   ADVERTISEMENT
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > To unsubscribe from this group, send an email to:
        > soaplite-unsubscribe@yahoogroups.com
        >
        >
        >
        >
        >
        > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
        >
        >
        >
        >
        >

        ^byrne :/

      • Byrne Reese
        Were you interacting with a .NET server? I have done so in the past and it always forced my client (regardless of having the credentials there or not) to do
        Message 3 of 4 , Aug 28, 2003
          Were you interacting with a .NET server? I have done so in the past and it
          always forced my client (regardless of having the credentials there or
          not) to do the little 401 loop you described.

          SOAP::Lite puts the auth credentials in the request, if they are
          specified. It doesn't wait for someone to ask for them...

          > Thanks a lot Byrne,
          >
          > your are definitely right. I tested the code with another server, and it
          > works
          > pretty good.
          > I found that the problem which i met came from the Apache Axis server
          > itself.
          >
          > when the client program sent a SOAP message to the server, it sent it
          > without any
          > authentication parameters in the HTTP header. If the server requires such
          > kind of
          > information, it sends back a '401 Unauthorized' message, thus the client
          > sends
          > back another HTTP message with the
          > authentication parameters.
          >
          > In the Apache Axis, the server gets the client message without the
          > authentication
          > parameters and sends back a '500 Internal Server Error' !! it might be a
          > misconfiguration from us!! Is there any way to force SOAP::Lite to send
          > the
          > authentication info in the first message without modifying the code?
          >
          > Thanks for any pointers!
          > Best regards,
          > lina
          >
          >
          > Byrne Reese wrote:
          >
          >> You will need to wrap your authentication code in a BEGIN block... like
          >> so:
          >>
          >> BEGIN {
          >> sub SOAP::Transport::HTTP::Client::get_basic_credentials {
          >> return 'username' => 'password';
          >> }
          >> }
          >>
          >> >
          >> >
          >> >
          >> >
          >> > Hi,
          >> >
          >> > I'm getting an error when I'm trying to use the
          >> > Authentication Basic in SOAP::Lite.
          >> > I'm using a Soap::Lite based Perl client accessing
          >> > Apache Axis based on java service.
          >> > I verified if the LWP::Authen::Basic module is well
          >> > installed as well as other modules.
          >> > I read the http://guide.soaplite.com/ and I tried to
          >> > use all the techniques mentioned in the guide to pass
          >> > the user and password, they don't seem to work!
          >> > Looking at the code, nothing seems to be implemented!
          >> >
          >> > Here's a part of my perl client code:
          >> >
          >> > #! /usr/bin/perl -w
          >> >
          >> > use Data::Dumper;
          >> > use Env;
          >> > use SOAP::Lite +trace =
          >> > on_fault =
          >> > eval { die ref $res ?
          >> > $res-
          >> > $soap-
          >> > return ref $res ? $res : new
          >> > SOAP::SOM;
          >> > };
          >> >
          >> > $HOST="http://quadri:4043/xxxxxxx/HelloIF";
          >> > $NS="urn:x-netcelo:xxxxxxxxx.HelloIF";
          >> > $PHRASE=shift;
          >> >
          >> > my $soap= SOAP::Lite
          >> > -
          >> > -
          >> > -
          >> >
          >> > sub
          >> > SOAP::Transport::HTTP::Client::get_basic_credentials {
          >> > return 'username' =
          >> > }
          >> >
          >> > my $som=$soap
          >> > -
          >> > print "The response from the server was: \n"
          >> > .$som-
          >> > 1;
          >> >
          >> > Here is a trace fragment for the call from perl
          >> > client: (I used Dumper method in the method
          >> > "send_receive" from /SOAP/Transport/HTTP.pm to dump
          >> > the $req (an instance from the HTTP::Request class) )
          >> >
          >> >
          >> > bless( {
          >> > '_method' =
          >> > '_headers' =
          >> > 'soapaction'
          >> > =
          >> > '"urn:x-netcelo:webServices.HelloIF#sayHello"',
          >> >
          >> > 'content-type'
          >> > =
          >> > charset=utf-8',
          >> >
          >> > 'content-length' =
          >> > 'accept' =
          >> >
          >> > 'text/xml',
          >> >
          >> > 'multipart/*'
          >> > ]
          >> > },
          >> > 'HTTP::Headers' ),
          >> > '_uri' =
          >> > 'http://quadri:4043/wservices/HelloIF')},
          >> > 'URI::http' ),
          >> > '_content' =;?xml version="1.0"
          >> > encoding="UTF-8"?
          >> >>;SOAP-ENV:Envelope
          >> > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
          >> > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
          >> > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
          >> > xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
          >> > xmlns:xsd="http://www.w3.org/1999/XMLSchema"
          >> >
          >> > >;SOAP-ENV:Body
          >> > >;namesp1:sayHello
          >> > xmlns:namesp1="urn:x-netcelo:webServices.HelloIF"
          >> > >;c-gensym4 xsi:type="xsd:string"
          >> >
          >> > ;/c-gensym4;/namesp1:sayHello;/SOAP-ENV:Body;/SOAP-ENV:Envelope
          >> >
          >> > }, 'HTTP::Request' );
          >> >
          >> > If we modify SOAP/Transport/HTTP.pm (send_recieve) we
          >> > can explicitly add the basic_authentication header.
          >> > However we have found no correct way of passing the
          >> > authentication parameters with the standard SOAP::Lite
          >> > interface. The "proxy" method accepts parameters that
          >> > are methods from LWP::UserAgent, but they are
          >> > not used....
          >> >
          >> > What am I missing?
          >> > Thanks for your help..
          >> >
          >> > Best regards,
          >> > Lina
          >> >
          >> >
          >> >
          >> >
          >> >
          >> >
          >> >
          >> >
          >> >
          >> > Yahoo! Groups Sponsor
          >> >
          >> >
          >> > ADVERTISEMENT
          >> >
          >> >
          >> >
          >> >
          >> >
          >> >
          >> >
          >> >
          >> >
          >> > To unsubscribe from this group, send an email to:
          >> > soaplite-unsubscribe@yahoogroups.com
          >> >
          >> >
          >> >
          >> >
          >> >
          >> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
          >> >
          >> >
          >> >
          >> >
          >> >
          >>
          >> ^byrne :/
          >


          ^byrne :/
        Your message has been successfully submitted and would be delivered to recipients shortly.