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

Basic Authentication with SOAP::Lite?

Expand Messages
  • Lina Alshaal
    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
    Message 1 of 4 , Aug 20, 2003
    • 0 Attachment
      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 => 'debug',
      on_fault => sub { my($soap, $res) = @_;
      eval { die ref $res ?
      $res->faultstring :
      $soap->transport->status };
      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
      ->readable(1)
      ->uri($NS)
      ->proxy($HOST );

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

      my $som=$soap
      ->sayHello(SOAP::Data->name("" => "$PHRASE"));
      print "The response from the server was: \n"
      .$som->result. "\n";
      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' => 'POST',
      '_headers' => bless( {
      'soapaction'
      =>
      '"urn:x-netcelo:webServices.HelloIF#sayHello"',

      'content-type'
      => 'text/xml;
      charset=utf-8',

      'content-length' => 560,
      'accept' => [

      'text/xml',

      'multipart/*'
      ]
      },
      'HTTP::Headers' ),
      '_uri' => bless( do{\(my $o =
      '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"

      >toto</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
    • 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 2 of 4 , Aug 24, 2003
      • 0 Attachment
        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 3 of 4 , Aug 26, 2003
        • 0 Attachment
          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=&quot;http://quadri:4043/xxxxxxx/HelloIF&quot;;
          > $NS=&quot;urn:x-netcelo:xxxxxxxxx.HelloIF&quot;;
          > $PHRASE=shift;
          >
          > my $soap= SOAP::Lite
          >         -
          >         -
          >         -
          >
          > sub
          > SOAP::Transport::HTTP::Client::get_basic_credentials {
          >   return 'username' =
          >        }
          >
          > my $som=$soap
          >         -
          > print &quot;The response from the server was: \n&quot;
          > .$som-
          > 1;
          >
          > Here is  a  trace fragment for the call from perl
          > client:  (I used Dumper method in the method
          > &quot;send_receive&quot; from /SOAP/Transport/HTTP.pm to dump
          > the $req (an instance from the  HTTP::Request class) )
          >
          >
          >  bless( {
          >                  '_method' =
          >                  '_headers' =
          >                                         'soapaction'
          > =
          > '&quot;urn:x-netcelo:webServices.HelloIF#sayHello&quot;',
          >
          >                                         'content-type'
          > =
          > charset=utf-8',
          >
          > 'content-length' =
          >                                         'accept' =
          >
          > 'text/xml',
          >
          > 'multipart/*'
          >                                                     ]
          >                                       },
          > 'HTTP::Headers' ),
          >                  '_uri' =
          > 'http://quadri:4043/wservices/HelloIF')},
          > 'URI::http' ),
          >                  '_content' =;?xml version=&quot;1.0&quot;
          > encoding=&quot;UTF-8&quot;?
          >>;SOAP-ENV:Envelope
          > xmlns:SOAP-ENC=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;
          > SOAP-ENV:encodingStyle=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;
          > xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;
          > xmlns:xsi=&quot;http://www.w3.org/1999/XMLSchema-instance&quot;
          > xmlns:xsd=&quot;http://www.w3.org/1999/XMLSchema&quot;
          >
          >   >;SOAP-ENV:Body
          >     >;namesp1:sayHello
          > xmlns:namesp1=&quot;urn:x-netcelo:webServices.HelloIF&quot;
          >       >;c-gensym4 xsi:type=&quot;xsd:string&quot;
          >
          > ;/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 &quot;proxy&quot; 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 4 of 4 , Aug 28, 2003
          • 0 Attachment
            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.