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

Hi guys
i am starting to have a suspicion that it is not me, but SOAP::Lite or HTTP::Cookies
issue, i have to perform SOAP calls, and it authentication on a server side is cookie based

i open my SOAP session like this
my $soap = new SOAP::Lite; $soap->uri($nameSpace); $soap->proxy($proxy, cookie_jar => HTTP::Cookies->new(ignore_discar +d =>1));
then i am performing my first authentication call, and if it is sucesfull then i am getting cookie in return
my $SessionLoginTechnicianMethod = SOAP::Data->name('SessionLoginTechn +ician') ->attr({xmlns => $nameSpa +ce}); my @SessionLoginTechnicianValues = ( SOAP::Data->name('TechName' => $us +erid), SOAP::Data->name('Password' => $pa +ssword) ); my $commID = $soap->call($SessionLoginTechnicianMethod => @SessionLogi +nTechnicianValues); my $communityID = $commID->valueof('//CommunityID');
and that goes fine
here is part of a trace with cookie
Client-SSL-Cipher: RC4-MD5 Client-SSL-Warning: Peer certificate not verified Set-Cookie: SESSIONID=lMcsJpx35LSuECd34f/90u2vsRGK8BLBx96rHu/cyIgY/xbf ++YMD0BhDDP04vfKbHfhL; path=/;version=1 X-Powered-By: ASP.NET
then nect call right after that not setting cookie
Accept: text/xml Accept: multipart/* Accept: application/soap User-Agent: SOAP::Lite/Perl/0.69 Content-Length: 689 Content-Type: text/xml; charset=utf-8
and call right after that
is using issued cookie
Accept: text/xml Accept: multipart/* Accept: application/soap User-Agent: SOAP::Lite/Perl/0.69 Content-Length: 654 Content-Type: text/xml; charset=utf-8 Cookie: $Version=1; SESSIONID="2Ho+EHPPfAlGDPFA6xobS55byc8/38TeYhFl6UW +Nw70iJBWsWADBASxpQRmlRGNsYQIG"; $Path="/"
why this is happening? and also why cookie is not the same one?
if i look at previous trace logs, that cookie is form previous log...

Replies are listed 'Best First'.
Re: cookie based SOAP
by olus (Curate) on Jan 04, 2008 at 11:41 UTC
    You are only taking the value of CommunityID from the response.
    I don't see the code where you get your SESSIONID cookie.
    You must fetch that cookie and provide it in the next calls to the service.

    The docs for HTTP::Cookies says it can be accomplished this way:
    $cookie_jar->extract_cookies( $response )
    After getting the cookies, you set them on SOAP::Transport::HTTP
    $soap->transport->cookie_jar($cookies);
    Now you can make more calls on the service.

    Update: re-read the doc with more attention, and the cookie_jar should handle the cookies.
      The point of a cookie_jar is to not have to do it manually, see SOAP::Transport
Re: cookie based SOAP
by Anonymous Monk on Jan 04, 2008 at 10:32 UTC
    Your code only has one call. Try upgrading :/