habit_forming has asked for the wisdom of the Perl Monks concerning the following question:

Oh great and powerful Monks, a little help please.
I need to set a cookie in a freshly created but not yet used SOAP::Lite object. The cookie needs to go out with the initial POST. I have tried both:
$soap_obj = SOAP::Lite->uri($uri) ->proxy($proxy,timeout => $timeout); $soap_obj->transport->cookie_jar($cookie_jar);
and
$soap_obj = SOAP::Lite->uri($uri) ->proxy($proxy,timeout => $timeout cookie_jar => $cookie_jar);
where  $cookie_jar is created like
require HTTP::Cookies; my $cookie_jar = HTTP::Cookies->new(ignore_discard => 1); $cookie_jar->set_cookie(undef, "my_cookie", $value, '/', $cookie_domain, '8080', #Yes 8080 is https. undef, 1, 600);
What am I doing wrong? I have looked at the docs on CPAN and at www.soaplite.com. I just can't seem to get it to work.

Cheers!
--habit

Replies are listed 'Best First'.
Re: SOAP::Lite and HTTP::Cookies
by dtr (Scribe) on Aug 24, 2005 at 17:08 UTC

    After some experimenting and digging through various modules, I couldn't make the HTTP::Cookies thing work either. However, the following code sends the cookie (according to a trace from ethereal), so should hopefully do what you want:-

    #! perl use strict; use warnings; use SOAP::Lite; use HTTP::Headers; my $hdr = HTTP::Headers->new( Cookie => "session=my_session_id", ); print SOAP::Lite -> uri('http://www.soaplite.com/Temperatures') -> proxy('http://services.soaplite.com/temper.cgi', default_headers => $hdr, ) -> f2c(100) -> result;

      Thank you for the reply but actually, that doesn't work. I have solved it though. I am using GLOBs/function references and intercepting the calls to SOAP::Transport::HTTP::Client::send_receive and inserting a "Cookie" parameter directly to HTTP::Headers ref that is being passed in.

      --habit