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

Should I be able to see the cookies in the request header?

Expand Messages
  • Randall Marbach
    Hi All Should I be able to see the cookie info in the +debug output of my client showing the request header contents. It is not there. My early attempts at
    Message 1 of 1 , Jul 20, 2005
    • 0 Attachment
      Hi All

      Should I be able to see the cookie info in the +debug
      output of my client showing the request header
      contents. It is not there. My early attempts at
      trying to get the examples in ch07 of Programing Web
      Services with Perl are failing and near as I can tell
      it is because the client is not populating the header
      with the cookie info.

      Here is the relevant debug output:
      ...
      SOAP::Transport::HTTP::Client::send_receive:
      HTTP::Request=HASH(0x1f9ac7c)
      SOAP::Transport::HTTP::Client::send_receive: POST
      http://localhost:9000 HTTP/1.1

      Accept: text/xml
      Accept: multipart/*
      Accept: application/soap
      Content-Length: 502
      Content-Type: text/xml; charset=utf-8
      SOAPAction: "urn:WishListCustomer#BooksByTitle"

      <?xml version="1.0" encoding="UTF-8"?><soap:Envelope
      xmlns:xsi="http://www.w3.or
      g/2001/XMLSchema-instance"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encodi
      ng/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      soap:encodingStyle="http://sch
      emas.xmlsoap.org/soap/encoding/"
      xmlns:soap="http://schemas.xmlsoap.org/soap/env
      elope/"><soap:Body><namesp1:BooksByTitle
      xmlns:namesp1="urn:WishListCustomer"><c
      -gensym3
      xsi:type="xsd:string">Software</c-gensym3></namesp1:BooksByTitle></soap
      :Body></soap:Envelope>
      SOAP::Transport::HTTP::Client::send_receive:
      HTTP::Response=HASH(0x2118214)
      SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1
      200 OK
      Date: Wed, 20 Jul 2005 18:05:53 GMT
      Server: libwww-perl-daemon/1.36
      Content-Length: 542
      Content-Type: text/xml; charset=utf-8
      Client-Date: Wed, 20 Jul 2005 18:05:53 GMT
      Client-Peer: 127.0.0.1:9000
      Client-Response-Num: 1
      SOAPServer: SOAP::Lite/Perl/0.65_6

      <?xml version="1.0" encoding="UTF-8"?><soap:Envelope
      xmlns:xsi="http://www.w3.or
      g/2001/XMLSchema-instance"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encodi
      ng/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      soap:encodingStyle="http://sch
      emas.xmlsoap.org/soap/encoding/"
      xmlns:soap="http://schemas.xmlsoap.org/soap/env
      elope/"><soap:Body><namesp1:BooksByTitleResponse
      xmlns:namesp1="urn:WishListCust
      omer"><soapenc:Array
      soapenc:arrayType="xsd:anyType[0]"
      xsi:type="soapenc:Array"

      /></namesp1:BooksByTitleResponse></soap:Body></soap:Envelope>
      SOAP::Deserializer::deserialize: ()
      SOAP::Parser::decode: ()
      SOAP::SOM::new: ()
      ...

      and here is the client code. . .
      TIA

      Randy

      use URI;
      use HTTP::Cookies;
      use SOAP::Lite +debug;
      # This is included only to avoid re-copying the cookie
      # code.
      use WishListCustomer; # for make_cookie

      my ($user, $passwd) = (shift, shift);
      die "USAGE: $0 username passwd [ endpoint ]\n"
      unless ($user and $passwd);

      # To allow more flexibility in specifying the
      endpoint, the
      # URI class is used on the URL to properly extract the
      host
      # and port values for creating the cookies.
      my $endpoint = shift || 'http://localhost:9000';
      #my $endpoint = shift ||
      'http://localhost.localdomain:9000';
      my $uri = URI->new($endpoint);
      my $cookie = WishListCustomer::make_cookie($user,
      $passwd);
      print "$cookie\n";
      my $cookie_jar = HTTP::Cookies->new(ignore_discard =>
      1);
      $cookie_jar->set_cookie(0, user => $cookie, '/',
      $uri->host,
      $uri->port);
      print "$cookie_jar\n";
      #
      # Create the SOAP handle, with access to the cookie...
      #
      my $soap = SOAP::Lite->uri('urn:WishListCustomer')
      ->proxy($endpoint,
      cookie_jar => $cookie_jar);

      # ...and call the Wishlist method, checking for errors
      my $result = $soap->BooksByTitle("Software");

      if ($result->fault) {
      die "$0: Operation failed: " .
      $result->faultstring;
      }
      my $books = $result->result;
      ...



      ____________________________________________________
      Start your day with Yahoo! - make it your home page
      http://www.yahoo.com/r/hs
    Your message has been successfully submitted and would be delivered to recipients shortly.