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

Problem with cookies

Expand Messages
  • CristiAn Fuenzalida
    Hello :-) , I m using SOAP::Lite/Perl/0.65_6, and have a problem with cookies. I want to first call a login service which returns a key, and then call a
    Message 1 of 1 , Dec 12, 2005
    • 0 Attachment
      Hello :-) ,

      I'm using SOAP::Lite/Perl/0.65_6, and have a problem with cookies. I want to first call a login service which returns a key, and then call a function that return some values only if the user was succesfully logged in (if the client sent a valid key to the server using cookies). The server use cookies to return the key, but it looks like the client isn't recieving, storing or resending it. I said so, because when i dump the request from the client on the second service call, i don't see the headers for the cookies the server set, nor in the dump of the execution appears the cookies the client should set(see code below)

      Does anybody have any idea about what's happening ?...



      This is part of the Client code

        my $cookie_jar = HTTP::Cookies->new(ignore_discard => 1, autosave=>1);
        my $soap = SOAP::Lite
          -> uri ('http://www.server.com/server',
                   cookie_jar  => $cookie_jar
                  )
          -> encoding('iso-8859-1')
          -> proxy('http://example.com/server.cgi');

         # First call
         my $som = $soap->login($email, $password);

         # Second call, so the cookies should be sent
         $som =  $soap->getTypes();


      The server set the cookies using this function, where $r is the Apache request.
        $r->headers_out->add('Set-Cookie' => "key=$key; path=/;$domain$expires");

      I also made a Dump of the SOM, and i noticed that the headers for the cookies are there inside the _request HTTP::Request object.
       => bless( {
                   'client-response-num' => '1',
                   'soapserver' => 'SOAP::Lite/Perl/0.65_6',
                   'content-type' => 'text/xml; charset=iso-8859-1',
                   'connection' => 'close',
                   'date' => 'Mon, 12 Dec 2005 14:46:01 GMT',
                   'server' => 'Apache',
                   'set-cookie' => [
                                     'key=59843KyV5Mlo7; path=/; expires=Sun, 12-Mar-06 14:46:09 GMT; domain=.example.com'
                                   ],
                   'client-date' => 'Mon, 12 Dec 2005 14:46:09 GMT',
                    'content-length' => '660'
                  }, 'HTTP::Headers' ),




      The result of the first call is (using    'use SOAP::Lite +"debug"'  or 'use SOAP::Lite +"trace"' )
      ...
      Content-Type: text/xml; charset=iso-8859-1
      SOAPAction: "http://www.example.com/server#login"

      <?xml version="1.0" encoding="iso-8859-1"?><soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><namesp1:login xmlns:namesp1="http://www.server.com/server"><email xsi:type="xsd:string">cfuenzal@...</email><password xsi:type="xsd:string">pass</password></namesp1:login></soap:Body></soap:Envelope>
      SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x8733bdc)
      SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
      Connection: close

      Date: Mon, 12 Dec 2005 15:18:46 GMT
      Server: Apache
      Content-Type: text/xml; charset=iso-8859-1
      Client-Response-Num: 1
      Set-Cookie: key=59843KyV5Mlo7; path=/; domain=.example.com;               <-- HERE IS THE COOKIE SENT FROM THE SERVER
      SOAPServer: SOAP::Lite/Perl/0.65_6

      <?xml version="1.0" encoding="iso-8859-1"?><soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><namesp3:loginResponse xmlns:namesp3="http://www.server.com/server"><return_code xsi:type="xsd:integer">1</return_code><msg xsi:type="xsd:string">Logging OK</msg></namesp3:loginResponse></soap:Body></soap:Envelope>


      And the second call has as result...


      SOAPAction: "http://www.server.com/server#getTypes"

      <?xml version="1.0" encoding="iso-8859-1"?><soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><namesp2:getTypes xmlns:namesp2="http://www.server.com/server" xsi:nil="true" /></soap:Body></soap:Envelope>
      SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x879adbc)
      SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
      Connection: close
      Server: Apache
      Content-Length: 1063
      Content-Type: text/xml; charset=iso-8859-1
      Client-Response-Num: 1
      SOAPServer: SOAP::Lite/Perl/0.65_6


      Thanks in advance,

      CristiAn.
    Your message has been successfully submitted and would be delivered to recipients shortly.